Add dashboard UI and secure API endpoints

This commit is contained in:
2026-01-27 15:20:10 +01:00
parent 41949fe596
commit 5905b16d50
12 changed files with 1193 additions and 181 deletions
+18 -2
View File
@@ -1,11 +1,27 @@
const fs = require('node:fs');
const path = require('node:path');
const {MongoClient, ServerApiVersion} = require('mongodb');
const {mongodb} = require("./config.json");
const loadConfig = () => {
const configPath = path.join(__dirname, 'config.json');
if (fs.existsSync(configPath)) {
return require(configPath);
}
return {};
};
const config = loadConfig();
const MONGODB_URI = process.env.MONGODB_URI || config.mongodb;
let dbClient;
async function connectToDatabase() {
if (!dbClient) {
dbClient = new MongoClient(mongodb, {
if (!MONGODB_URI) {
throw new Error('Missing MongoDB connection string.');
}
dbClient = new MongoClient(MONGODB_URI, {
serverApi: {
version: ServerApiVersion.v1,
strict: true,