From e11dc9345a753d43e8ab92638fad392ec546b8bb Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Sun, 15 Jun 2025 09:56:43 +0000
Subject: [PATCH] GS-2160
---
app.js | 60 ++++++++++++++++++++++++++++++++++--------------------------
1 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/app.js b/app.js
index 7b99446..97f095d 100644
--- a/app.js
+++ b/app.js
@@ -6,6 +6,7 @@
const fs = require("node:fs")
const db = require("./lib/db")
+const libIlias = require("lib/libIlias")
const settings = require("./settings")
const search = require("./lib/search.js")
@@ -32,11 +33,28 @@
}
})
+/////// 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) {
@@ -79,6 +97,19 @@
else {
return res.code(404).send({status: "error", msg: "not found"})
}
+ })
+
+ .delete("/api/user/:usr_id", function (req, res) {
+ const {usr_id} = req.params
+ if (!usr_id || isNaN(Number(usr_id))) {
+ return res.code(500).send({status: "error", msg: "userId error"})
+ }
+ else {
+ const res2 = libIlias.deleteUser(usr_id)
+ console.log(res2)
+ return res.send(res2)
+ }
+
})
/////// ref_id / obj_id ////////////////////////////////////////////////////////////////
@@ -156,24 +187,8 @@
}
})
-/////// 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 ////////////////////////////////////////////////////////////////
+/////// STATIC / SPA ////////////////////////////////////////////////////////////////
fastify.register(require('@fastify/static'), {
@@ -182,13 +197,6 @@
// constraints: { host: 'example.com' } // optional: default {}
})
-
-
-// fastify.get('*', function (req, reply) {
-// console.log("!!!!!!!!! send index")
-// // index.html should never be cached
-// reply.sendFile('dist/index.html', {maxAge: 0, immutable: false})
-// })
const indexFile = fs.readFileSync(path.join(__dirname, "vue/dist", 'index.html'), 'utf8')
fastify.setNotFoundHandler(function (req, res) {
--
Gitblit v1.8.0