From 8d33fafb3224360f49f6ebc9e1b98f4fbdc1d1ad Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Wed, 25 Jun 2025 07:09:10 +0000
Subject: [PATCH] GS-2169

---
 app.js |   41 ++++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/app.js b/app.js
index e31d23f..97cce6f 100644
--- a/app.js
+++ b/app.js
@@ -29,7 +29,7 @@
       return res.send({status: "error", error: "access denied"})
    }
    else {
-      console.log("NO AUTH FOR ", req.url)
+      console.log("AUTH FOR ", req.url)
    }
 })
 
@@ -37,18 +37,28 @@
 
 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
+   .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)
+      }
+   })
+   .post("/api/search/reindex", async function (req, res) {
+      console.log("REINDEX ++++")
+      const start = Date.now()
+      await searchLib.doIndex().catch(console.error)
+      return res.send({
+         status: "ok",
+         msg: `reindexed in ${Date.now() - start} ms`,
+      })
+   })
 
 fastify
    /////// USER ////////////////////////////////////////////////////////////////
@@ -99,6 +109,11 @@
       }
    })
 
+   .post("/api/user", async function (req, res) {
+      const user = req.body
+      const res2 = await libIlias.importIliasUser(user) // TODO import or update if already available
+      return res.send(res2)
+   })
 
    .delete("/api/user", async function (req, res) { // DELETE ALL users
       const res2 = await libIlias.deleteAllUsers()

--
Gitblit v1.8.0