| | |
| | | |
| | | ///////////////////////////////////////////////////////////////////////// |
| | | |
| | | // Compress |
| | | let compress = require('@fastify/compress') |
| | | // fastify.register(compress, { global: true }) |
| | | fastify.register(compress) |
| | | |
| | | // AUTH |
| | | fastify.addHook("onRequest", async (req, res) => { |
| | | console.log(req.url) |
| | |
| | | .get("/api/user/login/:login", async function (req, res) { |
| | | const {login} = req.params |
| | | const user = await db.getUserByLogin(login) |
| | | if (user.length) { |
| | | return res.send(user[0]) |
| | | if (user) { |
| | | return res.send(user) |
| | | } |
| | | else { |
| | | return res.code(404).send({status: "error", msg: "not found"}) |
| | |
| | | return res.code(404).send({status: "error", msg: "not found"}) |
| | | } |
| | | }) |
| | | .get("/api/user/teilnahmen/:userId", async function (req, res) { |
| | | let userId = req.params.userId |
| | | console.log(`--------${userId}-----------`, typeof userId) |
| | | if(!userId || isNaN(Number(userId))) { |
| | | return res.code(500).send({status: "error", msg: "userId error"}) |
| | | } |
| | | const tn = await db.getUserTeilnahmen(userId) |
| | | if (tn) { |
| | | return res.send(tn) |
| | | } |
| | | else { |
| | | return res.code(404).send({status: "error", msg: "not found"}) |
| | | } |
| | | }) |
| | | |
| | | /////// ref_id / obj_id //////////////////////////////////////////////////////////////// |
| | | |