用于以类型安全的方式获取环境变量。
interface ENV { DATABASE: string URL: string } const appEnvironmentVariableManager = EnvironmentVariableManager.of() const database = appEnvironmentVariableManager.get('DATABASE') // success const name = appEnvironmentVariableManager.get('NAME') // type check passed const safeName = appEnvironmentVariableManager.safeGet('NAME') // type check error
Get the value of the environment variable.
safeGet, recklessGet
get, safeGet
Get the value of the environment variable. When the target key is not exist in variables, an error will be thrown.
get, recklessGet
用于以类型安全的方式获取环境变量。
interface ENV { DATABASE: string URL: string } const appEnvironmentVariableManager = EnvironmentVariableManager.of()
const database = appEnvironmentVariableManager.get('DATABASE') // success
const name = appEnvironmentVariableManager.get('NAME') // type check passed
const safeName = appEnvironmentVariableManager.safeGet('NAME') // type check error