REST Service for POPCORN - ILIAS
alex
2025-11-17 3d646156c378c6182e55c673c118c23d53ff0a05
app.js
@@ -30,7 +30,7 @@
    // console.log(req.url)
    const token = req.query.token
    if (token !== settings.authtoken && !req.url.startsWith("/ui/")) {
   if (token !== settings.authtoken && !req.url.startsWith("/ui/") && !req.url.startsWith("/api/version")) {
        log.error("# AUTH ERROR #", token)
        await promiseDelay(500) // delay response to avoid denial of service attacks
        res.code(403)
@@ -40,11 +40,19 @@
    }
})
/////// VERSION ////////////////////////////////////////////////////////////////
fastify.get("/api/version", async function (req, res) {
   const {version} = require("./package.json")
   return res.send({version})
})
/////// SEARCH ////////////////////////////////////////////////////////////////
const searchLib = require("./lib/search")
const {setStatus} = require("./lib/db")
searchLib.doIndex().catch(console.error)
fastify
    .get("/api/search/user", async function (req, res) {
        log.info(req.query)
@@ -67,10 +75,10 @@
        })
    })
fastify
    /////// USER ////////////////////////////////////////////////////////////////
fastify
    .get('/api/user', async function (req, res) {
        const {offset, limit, search} = req.query
        const users = await db.getUsers(offset, limit, search)