| | |
| | | |
| | | const searchLib = require("./lib/search") |
| | | searchLib.doIndex().catch(console.error) |
| | | fastify.get("/api/search/user", async function (req, res) { |
| | | console.log(req.query) |
| | | const search = req.query?.search |
| | | if (!search) { |
| | | return res.code(422).send({status: "error", msg: "no search"}) |
| | | } |
| | | else { |
| | | console.log(search) |
| | | const data = await searchLib.search(search) |
| | | return res.send(data) |
| | | } |
| | | }) |
| | | fastify |
| | | .get("/api/search/user", async function (req, res) { |
| | | console.log(req.query) |
| | | const search = req.query?.search |
| | | if (!search) { |
| | | return res.code(422).send({status: "error", msg: "no search"}) |
| | | } |
| | | else { |
| | | console.log(search) |
| | | const data = await searchLib.search(search) |
| | | return res.send(data) |
| | | } |
| | | }) |
| | | .post("/api/search/reindex", async function (req, res) { |
| | | console.log("REINDEX ++++") |
| | | const start = Date.now() |
| | | await searchLib.doIndex().catch(console.error) |
| | | return res.send({ |
| | | status: "ok", |
| | | msg: `reindexed in ${Date.now() - start} ms`, |
| | | }) |
| | | }) |
| | | |
| | | fastify |
| | | /////// USER //////////////////////////////////////////////////////////////// |