mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 10:41:36 +00:00
Add home page and search page
This commit is contained in:
parent
cbc3a2bf67
commit
2cc6a2912a
13 changed files with 210 additions and 69 deletions
14
api/search.js
Normal file
14
api/search.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
const fetch = require("node-fetch")
|
||||
const {render} = require("pinski/plugins")
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
route: "/(?:search|results)", methods: ["GET"], code: async ({url}) => {
|
||||
const query = url.searchParams.get("q") || url.searchParams.get("search_query")
|
||||
const fetchURL = new URL("http://localhost:3000/api/v1/search")
|
||||
fetchURL.searchParams.set("q", query)
|
||||
const results = await fetch(fetchURL.toString()).then(res => res.json())
|
||||
return render(200, "pug/search.pug", {results})
|
||||
}
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue