From 39c750d6c090be68003c4631f427ed13d8e282da Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Tue, 03 Jun 2025 15:17:39 +0000
Subject: [PATCH] adding links to ilias
---
app.js | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/app.js b/app.js
index 1b402ee..7507ec0 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)
@@ -43,6 +51,9 @@
})
.get("/user/userid/:userid", async function (req, res) {
const {userid} = req.params
+ if(!userid || isNaN(Number(userid))) {
+ return res.code(500).send({status: "error", msg: "userid error"})
+ }
const user = await db.getUserByUserId(userid)
if (user) {
return res.send(user)
@@ -85,6 +96,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