Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed May 29, 2024
1 parent b4e4a69 commit d2e82e0
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
},
"cSpell.words": [
"Sogou"
]
}
60 changes: 60 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,66 @@ paths:
error:
type: string
example: "Internal Server Error"

/bing:
get:
operationId: Bing Search
summary: Perform a search on Bing
description: Returns search results from Sogou based on the query parameter.
parameters:
- name: search
in: query
required: true
description: The search query.
schema:
type: string
responses:
"200":
description: A JSON array of search results.
content:
application/json:
schema:
type: array
items:
type: object
properties:
title:
type: string
description: The title of the search result.
example: "Example Search Result Title"
link:
type: string
description: The URL of the search result.
example: "https://example.com"
description:
type: string
description: A brief description of the search result.
example: "This is an example description of a search result."
text:
type: string
description: The text of the search result.
example: "This is an example text of a search result."
"400":
description: Bad request, search query parameter is missing.
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: "search query parameter is required"
"500":
description: Internal server error.
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: "Internal Server Error"

components:
securitySchemes:
apiKey:
Expand Down
3 changes: 3 additions & 0 deletions src/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export function asyncExpressMiddleware(fn) {
export function createCommonSearchAPI(options) {
return asyncExpressMiddleware(async (req, res) => {
const { search } = req.query;
if (!search) {
return res.status(400).json({ error: "search query is required" });
}
const browser = await puppeteer.connect({
browserWSEndpoint: process.env.PW_REMOTE_URL,
});
Expand Down

0 comments on commit d2e82e0

Please sign in to comment.