Skip to content

Commit

Permalink
Migration ES6: Config
Browse files Browse the repository at this point in the history
Related OWASP#152
  • Loading branch information
UlisesGascon committed Jan 26, 2020
1 parent a5c959d commit a779d68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var _ = require("underscore");
var path = require("path");
const _ = require("underscore");
const path = require("path");

var finalEnv = process.env.NODE_ENV || "development";
const finalEnv = process.env.NODE_ENV || "development";

var config = _.extend(
require(path.resolve(__dirname + "/../config/env/all.js")),
require(path.resolve(__dirname + "/../config/env/" + finalEnv.toLowerCase() + ".js") || {})
);
const allConf = require(path.resolve(__dirname + "/../config/env/all.js"))
const envConf = require(path.resolve(__dirname + "/../config/env/" + finalEnv.toLowerCase() + ".js")) || {}

console.log("Current Config:", config)
const config = { ...allConf, ...envConf }

console.log(`Current Config: ${config}`)

module.exports = config;
8 changes: 4 additions & 4 deletions config/env/all.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// default app configuration

var port = process.env.PORT || 4000;
var db = process.env.MONGOLAB_URI || process.env.MONGODB_URI;
const port = process.env.PORT || 4000;
let db = process.env.MONGOLAB_URI || process.env.MONGODB_URI;

if (!db) {
db = process.env.NODE_ENV === 'test' ? "mongodb://localhost:27017/nodegoat" : "mongodb://nodegoat:owasp@ds159217.mlab.com:59217/nodegoat";
}

module.exports = {
port: port,
db: db,
port,
db,
cookieSecret: "session_cookie_secret_key_here",
cryptoKey: "a_secure_key_for_crypto_here",
cryptoAlgo: "aes256",
Expand Down

0 comments on commit a779d68

Please sign in to comment.