move dotenv config from server index to the config file
This commit is contained in:
@@ -1,3 +1,17 @@
|
|||||||
|
import dotenv from "dotenv";
|
||||||
|
import fs from "fs";
|
||||||
|
dotenv.config();
|
||||||
|
if (process.env.NODE_ENV === "test"){
|
||||||
|
try{
|
||||||
|
const envConfig = dotenv.parse(fs.readFileSync('.test.env'));
|
||||||
|
for (const k of Object.keys(envConfig)) {
|
||||||
|
process.env[k] = envConfig[k];
|
||||||
|
}
|
||||||
|
}catch (e) {
|
||||||
|
//Use .env file values
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const SERVER_PORT:number = parseInt(process.env.SERVER_PORT, 10) || 8080;
|
const SERVER_PORT:number = parseInt(process.env.SERVER_PORT, 10) || 8080;
|
||||||
|
|
||||||
const VALID_EXPORT_TYPES: {[key:string]: string} = {
|
const VALID_EXPORT_TYPES: {[key:string]: string} = {
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import dotenv from "dotenv";
|
|
||||||
import * as bodyParser from 'body-parser';
|
import * as bodyParser from 'body-parser';
|
||||||
|
|
||||||
import * as routes from "./routes"
|
import * as routes from "./routes"
|
||||||
|
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user