implemented naas in to user frontend

This commit is contained in:
2026-04-21 21:49:54 +02:00
parent f8ab2490fe
commit 25709ea0d9
5 changed files with 122 additions and 13 deletions
+19 -2
View File
@@ -1,6 +1,6 @@
import express from "express";
import cors from "cors";
import env from "dotenv";
import dotenv from "dotenv";
import info from "./info.json" assert { type: "json" };
import { authenticate } from "./services/authentication.js";
@@ -18,9 +18,12 @@ import userMgmtRouterADMIN from "./routes/admin/userMgmt.route.js";
// API routes
import apiRouter from "./routes/api/api.route.js";
env.config();
dotenv.config();
const app = express();
const port = 8004;
const naasURL = process.env.NAAS_URL;
console.log(naasURL);
app.use(cors());
// Body-Parser VOR den Routen registrieren
@@ -47,6 +50,20 @@ app.listen(port, () => {
console.log(`Server is running on port: ${port}`);
});
app.get("/no", async (req, res) => {
try {
const response = await fetch(naasURL);
if (!response.ok) {
res.status(500).send("Request to no-as-a-service went wrong.");
}
const data = await response.json();
res.json(data);
} catch (error) {
console.error("Error communicating with no-as-a-service:", error);
res.status(500).send("Error communicating with no-as-a-service.");
}
});
app.get("/verify", authenticate, async (req, res) => {
res.status(200).json({ message: "Token is valid", user: req.user });
});