diff --git a/app.js b/app.js index 734a14b..bcf725f 100644 --- a/app.js +++ b/app.js @@ -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('-------------------------------------------------------'); diff --git a/logs-view/index.html b/logs-view/index.html new file mode 100644 index 0000000..e204d24 --- /dev/null +++ b/logs-view/index.html @@ -0,0 +1,464 @@ + + +
+ +