Skip to content

Commit

Permalink
[add] Crawler API based on idea2app/Web-file-cache
Browse files Browse the repository at this point in the history
[optimize] update Upstream packages

Signed-off-by: TechQuery <shiy2008@gmail.com>
  • Loading branch information
TechQuery committed Dec 28, 2024
1 parent 7c4fd63 commit 99ffe82
Show file tree
Hide file tree
Showing 5 changed files with 1,350 additions and 1,305 deletions.
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default tsEslint.config(
{
plugins: {
'@typescript-eslint': tsEslint.plugin,
// @ts-expect-error https://github.com/jsx-eslint/eslint-plugin-react/issues/3699
react: fixupPluginRules(reactPlugin),
'simple-import-sort': simpleImportSortPlugin,
},
Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,34 @@
"dependencies": {
"@mdx-js/loader": "^3.1.0",
"@mdx-js/react": "^3.1.0",
"@next/mdx": "^15.0.3",
"@sentry/nextjs": "^8.41.0",
"@next/mdx": "^15.1.3",
"@sentry/nextjs": "^8.47.0",
"@swc/helpers": "^0.5.15",
"classnames": "^2.5.1",
"copy-webpack-plugin": "^12.0.2",
"core-js": "^3.39.0",
"file-type": "^19.6.0",
"idea-react": "^2.0.0-rc.8",
"koajax": "^3.1.0",
"koajax": "^3.1.1",
"less": "^4.2.1",
"less-loader": "^12.2.0",
"license-filter": "^0.2.4",
"lodash": "^4.17.21",
"markdown-ime": "^1.0.3",
"marked": "^15.0.3",
"marked": "^15.0.4",
"mobx": "^6.13.5",
"mobx-github": "^0.3.5",
"mobx-i18n": "^0.6.0",
"mobx-react": "^9.1.1",
"mobx-react": "^9.2.0",
"mobx-restful": "^2.0.0",
"mobx-restful-table": "^2.0.1",
"next": "^15.0.3",
"next": "^15.1.3",
"next-pwa": "~5.6.0",
"next-ssr-middleware": "^0.8.9",
"next-with-less": "^3.0.1",
"primereact": "^10.8.5",
"react": "^18.3.1",
"react-bootstrap": "^2.10.6",
"react-bootstrap": "^2.10.7",
"react-bootstrap-editor": "^2.0.4",
"react-dom": "^18.3.1",
"remark-frontmatter": "^5.0.0",
Expand All @@ -46,36 +46,36 @@
"turndown": "^7.2.0",
"turndown-plugin-gfm": "^1.0.2",
"web-utility": "^4.4.2",
"webpack": "^5.96.1",
"webpack": "^5.97.1",
"yaml": "^2.6.1"
},
"devDependencies": {
"@babel/plugin-proposal-decorators": "^7.25.9",
"@babel/plugin-transform-typescript": "^7.25.9",
"@babel/preset-react": "^7.25.9",
"@eslint/compat": "^1.2.3",
"@babel/plugin-transform-typescript": "^7.26.3",
"@babel/preset-react": "^7.26.3",
"@eslint/compat": "^1.2.4",
"@eslint/eslintrc": "^3.2.0",
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
"@types/eslint-config-prettier": "^6.11.3",
"@types/eslint__eslintrc": "^2.1.2",
"@types/lodash": "^4.17.13",
"@types/next-pwa": "^5.6.9",
"@types/node": "^20.17.9",
"@types/react": "^18.3.12",
"@types/node": "^20.17.10",
"@types/react": "^18.3.18",
"@types/turndown": "^5.0.5",
"eslint": "^9.16.0",
"eslint-config-next": "^15.0.3",
"eslint": "^9.17.0",
"eslint-config-next": "^15.1.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react": "^7.37.3",
"eslint-plugin-simple-import-sort": "^12.1.1",
"get-git-folder": "^0.1.2",
"globals": "^15.13.0",
"globals": "^15.14.0",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"prettier": "^3.4.1",
"lint-staged": "^15.3.0",
"prettier": "^3.4.2",
"prettier-plugin-css-order": "^2.1.2",
"typescript": "~5.7.2",
"typescript-eslint": "^8.16.0"
"typescript-eslint": "^8.18.2"
},
"resolutions": {
"@types/node": "$@types/node",
Expand Down
32 changes: 32 additions & 0 deletions pages/api/crawler/task.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { githubClient } from 'mobx-github';

import { safeAPI } from '../core';

export interface CrawlerTask {
URI: string;
title?: string;
}

const CRAWLER_TOKEN = process.env.CRAWLER_TOKEN;

export default safeAPI(async ({ method, headers, body }, response) => {
if (
!CRAWLER_TOKEN ||
CRAWLER_TOKEN !== headers.authorization?.split(/\s+/)[1]
)
return void response.status(401).end();

if (method !== 'POST') return void response.status(405).end();

const { URI, title = URI } = body as CrawlerTask;

const { status, body: data } = await githubClient.post(
'repos/kaiyuanshe/OWS-cache/issues',
{
title,
body: `### URL\n\n${URI}`,
labels: ['crawler'],
},
);
response.status(status).send(data);
});
Loading

0 comments on commit 99ffe82

Please # to comment.