Ajout redirection des logs sur websocket et page /logs/view

This commit is contained in:
Arnaud Nelissen
2025-09-30 19:05:40 +02:00
parent 3ff1b73cd2
commit 539b6f262e
7 changed files with 633 additions and 9 deletions

11
app.js
View File

@@ -6,6 +6,7 @@ const express = require('express');
const fs = require('fs');
const http = require('http');
const https = require('https');
const path = require('path');
require('dotenv').config()
@@ -22,7 +23,7 @@ const credentials = {
};
const dbcontroller = require('./db');
const {firmware} = require('./services');
const {firmware, log} = require('./services');
const routes = require('./routes')
const app = express();
@@ -60,6 +61,11 @@ dbcontroller.init()
console.log('MongoDB Client initialized');
console.log('-------------------------------------------------------');
(async () => {
await log.attachLogService(httpServer, '/logs');
await log.attachLogService(httpsServer, '/logs');
})();
///// Startup HTTP Server
httpServer.listen(http_port, () => {
console.log('-------------------------------------------------------');
@@ -88,6 +94,9 @@ app.use(express.json());
app.use(express.raw({ type: 'application/cbor' }));
app.use(express.urlencoded({ extended: true }));
// Serve the log viewer HTML
app.use('/logs/view', express.static(path.join(__dirname, 'logs-view')));
app.use(function (req, res, next) {
// Log request
console.log('-------------------------------------------------------');