fix: change the order in which env vars are loaded

This commit is contained in:
zyachel 2022-06-05 21:13:47 +05:30
parent f39998d57b
commit 55c0eba6e4
2 changed files with 9 additions and 8 deletions

11
app.js
View File

@ -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
//-------------------------------------------------------------------------//

View File

@ -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
//---------------------------------------------------------------------------//