From 30e23caf7f93d68332ba8169ae770c21f1946173 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Fri, 4 Nov 2022 18:07:44 -0400 Subject: [PATCH] Added config options to define what host address and port to listen on --- build/etc/production.json | 4 ++++ config/default.json | 4 ++++ index.js | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build/etc/production.json b/build/etc/production.json index af20d17..f660081 100644 --- a/build/etc/production.json +++ b/build/etc/production.json @@ -1,4 +1,8 @@ { + "server": { + "address": "0.0.0.0", + "port": 3000 + }, "database": { "driver": "sqlite", "connection_string": "/opt/overseer/data/overseer.db" diff --git a/config/default.json b/config/default.json index 5d70d76..6f97fa3 100644 --- a/config/default.json +++ b/config/default.json @@ -1,4 +1,8 @@ { + "server": { + "address": "0.0.0.0", + "port": 3000 + }, "database": { "driver": "sqlite", "connection_string": "data/overseer.db" diff --git a/index.js b/index.js index e06826e..bea1024 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ const session = require('express-session'); // instantiate new express.js app const app = express(); -const port = 3000; +const config = require('config'); // initialize database connection (async () => { @@ -50,6 +50,6 @@ app.get('/item/:id/edit', itemRoutes.getItemEdit); app.post('/item/:id/edit', itemRoutes.postItemEdit); // start app -app.listen(port, () => { - console.log(`Example app listening on port ${port}`); +app.listen(config.get('server.port'), config.get('server.address'), () => { + console.log(`Overseer is listening on port ${config.get('server.port')}.`); });