From 55c0eba6e47c85654242173796e76205328f5f31 Mon Sep 17 00:00:00 2001 From: zyachel Date: Sun, 5 Jun 2022 21:13:47 +0530 Subject: [PATCH] fix: change the order in which env vars are loaded --- app.js | 11 +++++++++-- server.js | 6 ------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index 04fc8b8..fa14571 100644 --- a/app.js +++ b/app.js @@ -3,12 +3,19 @@ const path = require('path'); const morgan = require('morgan'); const helmet = require('helmet'); const compression = require('compression'); -const app = express(); -// const movieRouter = require('./routes/movieRoutes'); +const dotenv = require('dotenv'); + const viewRouter = require('./routes/viewRoutes'); const globalErrorHandler = require('./controllers/errorControllers'); const { AppError } = require('./utils/errorUtils'); +const app = express(); + +//---------------------------------------------------------------------------// +// LOADING CONFIG FILE VARIABLES +//---------------------------------------------------------------------------// +dotenv.config({ path: './config.env' }); // loading .env variables + //-------------------------------------------------------------------------// // GLOBAL MIDDLEWARES //-------------------------------------------------------------------------// diff --git a/server.js b/server.js index 2af9f46..317ef0c 100644 --- a/server.js +++ b/server.js @@ -1,4 +1,3 @@ -const dotenv = require('dotenv'); const app = require('./app'); //---------------------------------------------------------------------------// @@ -16,11 +15,6 @@ process.on('unhandledRejection', err => { server.close(() => process.exit(1)); // shutting the system down gracefully }); -//---------------------------------------------------------------------------// -// LOADING CONFIG FILE VARIABLES -//---------------------------------------------------------------------------// -dotenv.config({ path: './config.env' }); // loading .env variables - //---------------------------------------------------------------------------// // STARTING SERVER //---------------------------------------------------------------------------//