generated from idea2app/Next-Bootstrap-ts
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] Crawler API based on idea2app/Web-file-cache
[optimize] update Upstream packages Signed-off-by: TechQuery <shiy2008@gmail.com>
- Loading branch information
Showing
5 changed files
with
1,356 additions
and
1,311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
Oops, something went wrong.
31f45c4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy preview for oss-toolbox ready!
✅ Preview
https://oss-toolbox-f5gxjgw4q-techquerys-projects.vercel.app
Built with commit 31f45c4.
This pull request is being automatically deployed with vercel-action