From ae7ad1c5f95db4ad49abeeb7cb4744897686d967 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Mon, 26 May 2025 14:23:40 +0000
Subject: [PATCH] adding generic db name

---
 app.js |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/app.js b/app.js
index 6240f3f..cd1c41a 100644
--- a/app.js
+++ b/app.js
@@ -19,16 +19,16 @@
 })
 
 fastify
-   .get('/api/users', async function (req, res) {
+   .get('/users', async function (req, res) {
       const {offset, limit} = req.query
       const users = await db.getUsers(offset, limit)
       return res.send(users)
    })
-   .get("/api/users/count", async function (req, res) {
+   .get("/users/count", async function (req, res) {
       const count = await db.getUserCount()
       return res.send(count)
    })
-   .get("/api/user/login/:login", async function (req, res) {
+   .get("/user/login/:login", async function (req, res) {
       const {login} = req.params
       const user = await db.getUserByLogin(login)
       if (user.length) {
@@ -38,11 +38,11 @@
          return res.code(404).send({status: "error", msg: "not found"})
       }
    })
-   .get("/api/user/userid/:userid", async function (req, res) {
+   .get("/user/userid/:userid", async function (req, res) {
       const {userid} = req.params
       const user = await db.getUserByUserId(userid)
-      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"})
@@ -52,7 +52,7 @@
 
 /////////////////////////////////////////////////////////////////////////
 
-fastify.listen({port: 4101}, function (err, address) {
+fastify.listen({port: settings.port}, function (err, address) {
    if (err) {
       fastify.log.error(err)
       process.exit(1)

--
Gitblit v1.8.0