-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.ts
45 lines (42 loc) · 900 Bytes
/
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
import dotenv from "dotenv";
dotenv.config();
interface IConfig {
port: number;
isProduction: boolean;
isDevelopment: boolean;
isTestEnvironment: boolean;
}
export const initConfig = (): IConfig => {
const { NODE_ENV, PORT } = process.env;
switch (NODE_ENV) {
case "development":
return {
isProduction: false,
isDevelopment: true,
isTestEnvironment: false,
port: Number(PORT) || 3001,
};
case "production":
return {
isProduction: true,
isDevelopment: false,
isTestEnvironment: false,
port: Number(PORT) || 3001,
};
case "test":
return {
isProduction: false,
isDevelopment: false,
isTestEnvironment: true,
port: Number(PORT) || 4000,
};
default:
return {
isProduction: false,
isDevelopment: true,
isTestEnvironment: false,
port: Number(PORT) || 3001,
};
}
};
export const config = initConfig();