From 441fa7efff1c342b5c0da53d2cbe55ea5fc17997 Mon Sep 17 00:00:00 2001 From: Niclas Thobaben Date: Thu, 24 Feb 2022 12:57:21 +0100 Subject: [PATCH] added logging --- index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 2fbed79..33c0901 100644 --- a/index.js +++ b/index.js @@ -1,11 +1,22 @@ const express = require('express') +const fs = require('fs'); +const dir = '/home/static'; const app = express(); app.use((req, res, next) => { + let tStart = new Date(); next() + let time = new Date() - tStart + console.log(`${req.method} ${res.statusCode} ${res.statusMessage} ${req.url} [${time}ms]`) }) -app.use(express.static('/home/static')) +app.use(express.static(dir)) + +console.log('-------------- Files --------------') +fs.readdirSync(dir).forEach(file => { + console.log(file); +}); +console.log('-----------------------------------') app.listen(80) console.log("Started Server on Port 80") \ No newline at end of file