-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
configuration.ts
73 lines (68 loc) · 1.65 KB
/
configuration.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
export const getConfig = (): AppConfig => {
return {
port: parseInt(process.env.PORT as string, 10) || 3000,
appEnv: process.env.APP_ENV as AppEnv,
jwtSecret: process.env.JWT_SECRET as string,
logLevel: process.env.LOG_LEVEL || 'info',
database: {
host: process.env.DB_HOST as string,
port: parseInt(process.env.DB_PORT as string, 10) || 5432,
user: process.env.DB_USER as string,
password: process.env.DB_PASSWORD as string,
dbName: process.env.DB_NAME as string,
},
cache: {
host: process.env.REDIS_HOST as string,
port: parseInt(process.env.REDIS_PORT as string, 10) || 6379,
password: process.env.REDIS_PASSWORD as string,
},
mail: {
from: process.env.MAIL_FROM as string,
transportOptions: {
host: process.env.MAIL_HOST as string,
port: parseInt(process.env.MAIL_PORT as string, 10),
auth: {
user: process.env.MAIL_AUTH_USER as string,
pass: process.env.MAIL_AUTH_PASS as string,
},
},
},
};
};
export interface AppConfig {
port: number;
appEnv: AppEnv;
jwtSecret: string;
logLevel: string;
database: DbConfig;
cache: CacheConfig;
mail: MailConfig;
}
export enum AppEnv {
DEV = 'dev',
TEST = 'test',
PROD = 'production',
}
export interface DbConfig {
host: string;
port: number;
user: string;
password: string;
dbName: string;
}
export interface CacheConfig {
host: string;
port: number;
password: string;
}
export interface MailConfig {
from: string;
transportOptions: {
host: string;
port: number;
auth: {
user: string;
pass: string;
};
};
}