-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
04bbb2f
commit b8ac526
Showing
4 changed files
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
MONGO_DB_HOST="YOUR_MONGO_DB_URI" | ||
COOKIE_SECRET="YOUR_COOKIE_SECRET" | ||
SSL_PASS_PHRASE="YOUR_SSL_PASS_PHRASE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const dotenv = require('dotenv'); | ||
const util = require('../util'); | ||
|
||
function configureEnv() { | ||
dotenv.config({ path: __dirname + '/../config/env/.env' }); | ||
checkEnvVariables(); | ||
} | ||
|
||
function checkEnvVariables() { | ||
const envList = ['SSL_PASS_PHRASE', 'COOKIE_SECRET']; | ||
envList.forEach((envVar) => { | ||
if (util.checkEnvVariable(envVar, 'string') === false) { | ||
throw new Error(`Missing ENV variable ${envVar}. Check ./src/config/env`); | ||
} | ||
}); | ||
} | ||
|
||
|
||
module.exports = { | ||
configureEnv, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
module.exports.init = function() { | ||
const dotenv = require('dotenv'); | ||
dotenv.config({ path: __dirname + '/config/env/.env' }); | ||
const { configureEnv } = require('./dotenv'); | ||
configureEnv(); | ||
|
||
const logger = require('./logger'); | ||
logger.configureLog(); | ||
|
||
const server = require('./server'); | ||
server.configureServer(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const _ = require('lodash'); | ||
|
||
module.exports.checkEnvVariable = function(variable, type) { | ||
const envVar = process.env[variable]; | ||
return !_.isNil(envVar) && typeof envVar === 'string'; | ||
}; |