generated from codepath/site-capstone
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
45 lines (38 loc) · 1.46 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require("dotenv").config();
require("colors");
const PORT = process.env.PORT ? Number(process.env.PORT) : 3001;
// const PORT = "https://focus-4-you.herokuapp.com";
const SECRET_KEY = process.env.SECRET_KEY || "secret_dev";
const IS_TESTING = process.env.NODE_ENV === "test";
function getDatabaseUri() {
const dbUser = process.env.DATABASE_USER || "postgres";
const dbPass = process.env.DATABASE_PASS
? encodeURI(process.env.DATABASE_PASS)
: "postgres";
const dbHost = process.env.DATABASE_HOST || "localhost";
const dbPort = process.env.DATABASE_PORT || 5432;
const dbTestName = process.env.DATABASE_TEST_NAME || "pomodoro_webapp_test";
const dbProdName = process.env.DATABASE_NAME || "pomodoro_webapp";
const dbName = process.env.NODE_ENV === "test" ? dbTestName : dbProdName;
return (
process.env.DATABASE_URL ||
`postgresql://${dbUser}:${dbPass}@${dbHost}:${dbPort}/${dbName}`
);
}
// Speed up bcrypt for tests when security isn't important
const BCRYPT_WORK_FACTOR = IS_TESTING ? 4 : 13;
// console.log("process.env".yellow, Object.keys(process.env));
console.log("Pomodoro Webapp Config:".red);
console.log("PORT:".blue, PORT);
console.log("SECRET KEY:".blue, SECRET_KEY);
console.log("IS_TESTING:".blue, IS_TESTING);
console.log("BCRYPT_WORK_FACTOR".blue, BCRYPT_WORK_FACTOR);
console.log("Database:".blue, getDatabaseUri());
console.log("---");
module.exports = {
PORT,
getDatabaseUri,
SECRET_KEY,
IS_TESTING,
BCRYPT_WORK_FACTOR,
};