-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
46 lines (37 loc) · 1.34 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
46
"use strict";
/** Shared config for application; can be required many places. */
require("dotenv").config();
require("colors");
const SECRET_KEY = process.env.SECRET_KEY || "secret-dev";
const PORT = +process.env.PORT || 3002;
// Use dev database, testing database, or via env var, production database
function getDatabaseUri() {
return (process.env.NODE_ENV === "test")
? "tour_for_all_test"
: process.env.DATABASE_URL || "tour_for_all";
}
// Speed up bcrypt during tests, since the algorithm safety isn't being tested
//
// WJB: Evaluate in 2021 if this should be increased to 13 for non-test use
const BCRYPT_WORK_FACTOR = process.env.NODE_ENV === "test" ? 1 : 12;
// Upload base folder
const UPLOAD_DIR = process.env.UPLOAD_DIR || "uploads";
const UPLOAD_URL = process.env.UPLOAD_URL || "/uploads";
const S3_UPLOAD = !!process.env.S3_UPLOAD || false;
const AWS_S3_BUCKET = process.env.AWS_S3_BUCKET || "tourforall";
console.log("tour_for_all Config:".green);
console.log("SECRET_KEY:".yellow, SECRET_KEY);
console.log("PORT:".yellow, PORT.toString());
console.log("BCRYPT_WORK_FACTOR".yellow, BCRYPT_WORK_FACTOR);
console.log("Database:".yellow, getDatabaseUri());
console.log("---");
module.exports = {
SECRET_KEY,
PORT,
BCRYPT_WORK_FACTOR,
getDatabaseUri,
UPLOAD_DIR,
UPLOAD_URL,
S3_UPLOAD,
AWS_S3_BUCKET
};