From e17e002b6902094d5811d0669313e67d96bb6ca4 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Thu, 05 Jun 2025 09:19:00 +0000
Subject: [PATCH] fixed user by login
---
app.js | 23 +++++++++++++++++++++--
1 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/app.js b/app.js
index c563cc2..f74787a 100644
--- a/app.js
+++ b/app.js
@@ -10,6 +10,11 @@
/////////////////////////////////////////////////////////////////////////
+// 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)
@@ -40,8 +45,8 @@
.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"})
@@ -60,6 +65,20 @@
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 ////////////////////////////////////////////////////////////////
--
Gitblit v1.8.0