add logging, fix title of page, revise docker compose file

This commit is contained in:
Aidan 2025-01-07 09:23:31 -05:00
parent d9d53290ea
commit 9deb1e3f37
3 changed files with 21 additions and 4 deletions

15
app.js
View File

@ -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`);
});
});

View File

@ -1,8 +1,12 @@
services:
app:
modules-app:
build: .
container_name: modules-app
restart: always
ports:
- "3000:3000"
volumes:
- .:/app
command: ["node", "app.js"]
environment:
- NODE_ENV=production

View File

@ -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"
}