From 9deb1e3f379293ccb869d3f9170750f01c8cde90 Mon Sep 17 00:00:00 2001 From: Aidan Date: Tue, 7 Jan 2025 09:23:31 -0500 Subject: [PATCH] add logging, fix title of page, revise docker compose file --- app.js | 15 +++++++++++++-- docker-compose.yml | 8 ++++++-- package.json | 2 ++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 91a8d29..9b94bd1 100644 --- a/app.js +++ b/app.js @@ -3,6 +3,8 @@ const fs = require('fs'); const path = require('path'); const validator = require('validator'); const helmet = require('helmet'); +var figlet = require("figlet"); +const morgan = require('morgan'); const app = express(); const PORT = 3000; @@ -23,6 +25,7 @@ app.use(helmet.contentSecurityPolicy({ upgradeInsecureRequests: [], }, })); +app.use(morgan('combined')); // routes app.get('/', (req, res) => { @@ -33,7 +36,7 @@ app.get('/apps', (req, res) => { fs.readFile('data/apps.json', (err, data) => { if (err) throw err; const apps = JSON.parse(data); - res.render('pages/apps', { title: 'Apps', apps: apps }); + res.render('pages/apps', { title: 'Apps | modules.', apps: apps }); }); }); @@ -90,5 +93,13 @@ app.get('/download', (req, res) => { }); app.listen(PORT, () => { - console.log(`Server is running on http://localhost:${PORT}`); + figlet("modules", function (err, data) { + if (err) { + console.log("Something went wrong..."); + console.dir(err); + return; + } + console.log(data); + console.log('\x1b[36m%s\x1b[0m', `Server is running on http://localhost:${PORT}\n`); + }); }); \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 644cd89..d7f2414 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,12 @@ services: - app: + modules-app: build: . + container_name: modules-app + restart: always ports: - "3000:3000" volumes: - .:/app - command: ["node", "app.js"] \ No newline at end of file + command: ["node", "app.js"] + environment: + - NODE_ENV=production \ No newline at end of file diff --git a/package.json b/package.json index 9ecad5f..c4efcf1 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,9 @@ "dependencies": { "ejs": "^3.1.10", "express": "^4.21.2", + "figlet": "^1.8.0", "helmet": "^8.0.0", + "morgan": "^1.10.0", "tailwindcss": "^3.4.17", "validator": "^13.12.0" }