mirror of
https://github.com/NebulaServices/Nebula.git
synced 2025-05-13 12:00:01 -04:00
Autofill backend
This commit is contained in:
parent
125878676f
commit
6937e7c993
1 changed files with 10 additions and 0 deletions
10
server.ts
10
server.ts
|
@ -77,6 +77,16 @@ app.register(fastifyStatic, {
|
|||
wildcard: false
|
||||
});
|
||||
|
||||
app.get("/search=:query", async (req, res) => {
|
||||
const { query } = req.params as { query: string }; // Define the type for req.params
|
||||
|
||||
const response = await fetch(
|
||||
`http://api.duckduckgo.com/ac?q=${query}&format=json`
|
||||
).then((apiRes) => apiRes.json());
|
||||
|
||||
res.send(response);
|
||||
});
|
||||
|
||||
app.setNotFoundHandler((req, res) => {
|
||||
res.sendFile("index.html"); // SPA catch-all
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue