This repository has been archived by the owner on Feb 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
59 lines (35 loc) · 1.87 KB
/
index.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
import pkg from '@/../package.json';
export const NODE_ENV = process.env.NODE_ENV ?? 'development';
export const IS_DEVELOPMENT = NODE_ENV === 'development';
export const IS_STAGING = NODE_ENV === 'staging';
export const IS_PRODUCTION = NODE_ENV === 'production';
export const IS_TEST = NODE_ENV === 'test';
export const APP_ENVS = ['.env', `.env.${NODE_ENV}`, '.env.local', `.env.${NODE_ENV}.local`];
export const APP_MODE = NODE_ENV?.toUpperCase();
export const APP_HTTPS = ['true', 'false'].includes(process.env.APP_HTTPS ?? '')
? (JSON.parse(process.env.APP_HTTPS as string) as boolean)
: false;
export const APP_HOST = process.env.APP_HOST ?? '127.0.0.1';
export const APP_PORT = /^\+?[1-9]\d*$/.test(process.env.APP_PORT ?? '')
? Number(process.env.APP_PORT)
: 3000;
export const APP_API_ROUTER_PREFIX = process.env.APP_API_ROUTER_PREFIX ?? 'api';
export const APP_VERSION = pkg.version;
export const APP_API_ROUTER_VERSION = `v${APP_VERSION.split('.')[0]}`;
export const APP_URL = `${
APP_HTTPS ? 'https' : 'http'
}://${APP_HOST}:${APP_PORT}/${APP_API_ROUTER_PREFIX}/${APP_API_ROUTER_VERSION}`;
export const APP_LOGGER_LEVEL = IS_PRODUCTION ? 'warn' : 'info';
export const APP_JWT_SECRET = process.env.APP_JWT_SECRET ?? 'secret';
export const APP_JWT_EXPIRES_IN = /^\+?[1-9]\d*$/.test(process.env.APP_JWT_EXPIRES_IN ?? '')
? Number(process.env.APP_JWT_EXPIRES_IN)
: 1000 * 60 * 60 * 24 * 7;
export const APP_DB_HOST = process.env.APP_DB_HOST ?? '127.0.0.1';
export const APP_DB_PORT = /^\+?[1-9]\d*$/.test(process.env.APP_DB_PORT ?? '')
? Number(process.env.APP_DB_PORT)
: 27_017;
export const APP_DB_NAME = process.env.APP_DB_NAME ?? 'app';
export const APP_DB_URI = `mongodb://${APP_DB_HOST}:${APP_DB_PORT}/${APP_DB_NAME}`;
export const ISO8601_FORMAT = undefined;
export const DATE_FORMAT = 'YYYY-MM-DD';
export const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';