From ab87bf915cbef62d5032b47540e593442c780193 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Fri, 20 Oct 2023 00:11:37 -0400 Subject: Change config format --- config.sample.js | 6 +++--- index.js | 5 ++--- utils.js | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config.sample.js b/config.sample.js index 1123a8a..60ef02b 100644 --- a/config.sample.js +++ b/config.sample.js @@ -1,5 +1,5 @@ module.exports = { - PORT: 8080, - MONGO_URI: 'mongodb://127.0.0.1:27017/flems', - BASE_URI: 'https://fle.ms/' + BIND: 8080, + MONGO: 'mongodb://user:password@127.0.0.1:27017/flems', + BASE: 'https://fle.ms/' } diff --git a/index.js b/index.js index db64231..ac4893a 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ const apiRoutes = require('./api-routes.js'); async function serve() { try { - await mongoose.connect(config.MONGO_URI, { + await mongoose.connect(config.MONGO, { useNewUrlParser: true, useUnifiedTopology: true }); @@ -27,8 +27,7 @@ async function serve() { app.use('/api', apiRoutes); app.use('/', routes); - const PORT = config.PORT || 80; - app.listen(PORT, () => { + app.listen(config.BIND || 8080, () => { console.log('[express] Webserver started.'); }); } diff --git a/utils.js b/utils.js index bd03888..eefc84d 100644 --- a/utils.js +++ b/utils.js @@ -29,7 +29,7 @@ const helperFunctions = { res.status(404).json({status: "ERROR", statusCode: 500, errorType: "INTERNAL", errorMessage: "Internal Server Error"}); }, sendSuccessfulSlugCreation : function (res, slug) { - res.status(201).json({status: "SUCCESS", statusCode: 201, data: {shortUrl: config.BASE_URI+slug}}); + res.status(201).json({status: "SUCCESS", statusCode: 201, data: {shortUrl: config.BASE+slug}}); }, isAlphaNumeric : function (str) { return str.match(/^[a-zA-Z0-9]+$/) !== null; -- cgit v1.2.3