| | |
| | | } |
| | | }) |
| | | |
| | | /////// SEARCH //////////////////////////////////////////////////////////////// |
| | | |
| | | 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 |
| | | /////// USER //////////////////////////////////////////////////////////////// |
| | | .get('/api/users', async function (req, res) { |
| | | const {offset, limit} = req.query |
| | | const users = await db.getUsers(offset, limit) |
| | | const {offset, limit, search} = req.query |
| | | const users = await db.getUsers(offset, limit, search) |
| | | return res.send(users) |
| | | }) |
| | | .get("/api/users/count", async function (req, res) { |
| | |
| | | } |
| | | }) |
| | | |
| | | /////// SEARCH //////////////////////////////////////////////////////////////// |
| | | |
| | | 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) |
| | | } |
| | | }) |
| | | |
| | | /////// STATIC //////////////////////////////////////////////////////////////// |
| | | |