From 21982a1d077140d85262a8c5b7c5e314ed48b9eb Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Mon, 02 Jun 2025 17:57:46 +0000
Subject: [PATCH] adding vue

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

diff --git a/app.js b/app.js
index 1b402ee..03ff46e 100644
--- a/app.js
+++ b/app.js
@@ -1,3 +1,4 @@
+const path = require("path")
 const fastify = require('fastify')({
    logger: true
 })
@@ -8,10 +9,17 @@
 
 /////////////////////////////////////////////////////////////////////////
 
+fastify.register(require('@fastify/static'), {
+   root: path.join(__dirname, 'vue/dist'),
+   prefix: '/ui/', // optional: default '/'
+   // constraints: { host: 'example.com' } // optional: default {}
+})
+
 // AUTH
 fastify.addHook("onRequest", async (req, res) => {
+   console.log(req.url)
    const token = req.query.token
-   if (token !== settings.authtoken) {
+   if (token !== settings.authtoken && !req.url.startsWith("/ui/")) {
       console.error("# AUTH ERROR #", token)
       await promiseDelay(500) // delay response to avoid denial of service attacks
       res.code(403)
@@ -85,6 +93,16 @@
          return res.code(404).send({status: "error", msg: "not found"})
       }
    })
+   .get("/kurs/:refId", async function (req, res) {
+      const {refId} = req.params
+      let data = await db.getKurs(refId)
+      if (data) {
+         return res.send(data)
+      }
+      else {
+         return res.code(404).send({status: "error", msg: "not found"})
+      }
+   })
    .get("/kurs/items/:refId", async function (req, res) {
       const {refId} = req.params
       let data = await db.getKursItems(refId)

--
Gitblit v1.8.0