First Committ
This commit is contained in:
27
config/envparser.js
Executable file
27
config/envparser.js
Executable file
@@ -0,0 +1,27 @@
|
||||
const DotEnv = require('dotenv')
|
||||
|
||||
let path
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'test':
|
||||
path = '.env.test'
|
||||
break
|
||||
case 'development':
|
||||
path = '.env.development'
|
||||
break
|
||||
default:
|
||||
path = '.env.production'
|
||||
break
|
||||
}
|
||||
|
||||
// console.log("PATH", path)
|
||||
const parsedEnv = DotEnv.config({ path }).parsed;
|
||||
|
||||
module.exports = function () {
|
||||
// Let's stringify our variables
|
||||
for (const key in parsedEnv) {
|
||||
if (typeof parsedEnv[key] === 'string') {
|
||||
// parsedEnv[key] = JSON.stringify(parsedEnv[key])
|
||||
}
|
||||
}
|
||||
return parsedEnv
|
||||
};
|
||||
Reference in New Issue
Block a user