Initial Commit
This commit is contained in:
40
src/utils/config.ts
Normal file
40
src/utils/config.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import * as env from 'env-var';
|
||||
import * as properUrlJoin from 'proper-url-join';
|
||||
const urlJoin = properUrlJoin as unknown as properUrlJoin.default;
|
||||
|
||||
const NODE_ENV = env.get('NODE_ENV').default("development").asString();
|
||||
const isProduction = NODE_ENV === 'production';
|
||||
|
||||
const envs = {
|
||||
NODE_ENV,
|
||||
// port of the server
|
||||
PORT: env.get('PORT').default('3000').asPortNumber(),
|
||||
// hostname of the server ('0.0.0.0' listens on all network interfaces)
|
||||
HOSTNAME: env.get('HOSTNAME').default('0.0.0.0').asString(),
|
||||
// base path
|
||||
BASE_PATH: env.get('BASE_PATH').default('/').asString(),
|
||||
// external base url
|
||||
EXTERNAL_BASE_URL: env.get('EXTERNAL_BASE_URL').asString(),
|
||||
|
||||
// url of redis session store
|
||||
REDIS_URL: env.get('REDIS_URL').required(isProduction).asString() || undefined,
|
||||
// cookie secret for the session id
|
||||
SESSION_SECRET: env.get('REDIS_URL').required(isProduction).default('keyboard cat').asString(),
|
||||
|
||||
// header where user info token is stored to request auth proxy
|
||||
USERINFO_HEADER: env.get('USERINFO_HEADER').asString() || undefined,
|
||||
// base url to init a logout or request user info
|
||||
AUTH_PROXY_URL: env.get('AUTH_PROXY_URL').asString() || undefined,
|
||||
// override base url to request user info
|
||||
AUTH_PROXY_USERINFO_URL: env.get('AUTH_PROXY_USERINFO_URL').asString() || undefined,
|
||||
// override base url to init a logout
|
||||
AUTH_PROXY_INIT_LOGOUT_URL: env.get('AUTH_PROXY_INIT_LOGOUT_URL').asString() || undefined,
|
||||
|
||||
};
|
||||
|
||||
|
||||
export const Config = {
|
||||
...envs,
|
||||
isProduction,
|
||||
EXTERNAL_BASE_URL: envs.EXTERNAL_BASE_URL || urlJoin(`http://${envs.HOSTNAME}${envs.PORT !== 80 ? `:${envs.PORT}` : ""}`),
|
||||
}
|
||||
Reference in New Issue
Block a user