forked from ERrijul8/redstone-cache-layer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.ts
54 lines (46 loc) · 1.15 KB
/
config.ts
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
47
48
49
50
51
52
53
54
const getEnv = (name: string, defaultValue: any) => {
return process.env[name] || defaultValue;
};
const getMode = () => {
return getEnv("MODE", "LOCAL");
};
const isProd = () => {
return getMode() === "PROD";
};
const isTest = process.env.NODE_ENV === "test";
const enableLiteMode = getEnv("LIGHT_MODE", false) === "true";
const dbUrls = {
local: "mongodb://localhost:27017/redstone",
prod: "",
};
if (!enableLiteMode && !isTest) {
dbUrls["prod"] = process.env.MONGO_DB_URL;
}
function getDbUrl() {
if (getMode() === "LOCAL") {
return dbUrls.local;
} else {
return dbUrls.prod;
}
}
const cacheTTLMilliseconds = !isTest ? 3 * 60 * 1000 : 0; // 3 minutes
const dbUrl = getDbUrl();
const bigLimitWithMargin = 1200;
const defaultLimit = 1;
const defaultLocalPort = 9000;
const awsSesRegion = "eu-north-1";
const isProduction = isProd();
const maxLimitForPrices = 3000;
const enableAmplitudeLogging = getEnv("ENABLE_AMPLITUDE_LOGGING", false);
export {
enableLiteMode,
dbUrl,
bigLimitWithMargin,
defaultLimit,
defaultLocalPort,
awsSesRegion,
isProduction,
maxLimitForPrices,
enableAmplitudeLogging,
cacheTTLMilliseconds,
};