Autofill backend

This commit is contained in:
rift 2023-12-29 11:20:07 -06:00
parent 125878676f
commit 6937e7c993

View file

@ -77,6 +77,16 @@ app.register(fastifyStatic, {
wildcard: false 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) => { app.setNotFoundHandler((req, res) => {
res.sendFile("index.html"); // SPA catch-all res.sendFile("index.html"); // SPA catch-all
}); });