src/module/config/entity/config.ts
Properties |
|
Methods |
Private Static variables |
Type : object
|
Default value : {}
|
Defined in src/module/config/entity/config.ts:6
|
Static get | ||||||
get(name: string)
|
||||||
Defined in src/module/config/entity/config.ts:8
|
||||||
Parameters :
Returns :
any
|
Static populate |
populate()
|
Defined in src/module/config/entity/config.ts:31
|
Returns :
void
|
Static push |
push(name: string, value: any)
|
Defined in src/module/config/entity/config.ts:22
|
Returns :
boolean
|
import { ConfigVariableNotFoundException } from '../../routing/exception/config.variable.not.found.exception'
import * as dotenv from 'dotenv'
export abstract class Config {
private static variables: object = {}
static get(name: string): any {
if (this.variables.hasOwnProperty(name)) {
return this.variables[name]
} else {
throw new ConfigVariableNotFoundException(name)
}
}
static push(name: string, value: any): boolean {
const overwritten: boolean = this.variables[name] !== undefined
this.variables[name] = value
return overwritten
}
static populate(): void {
dotenv.config()
for (const key of Object.keys(process.env)) {
this.push(key, process.env[key])
}
}
}