From fd1a50afe2174f8e5bfbf0703161426e46bc405a Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Tue, 10 Jun 2025 08:20:45 +0000
Subject: [PATCH] cleanup

---
 app.js |   46 ++++++++++++++++++++--------------------------
 1 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/app.js b/app.js
index 7b99446..7c2142b 100644
--- a/app.js
+++ b/app.js
@@ -32,11 +32,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) {
@@ -156,24 +173,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 +183,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