@herp-inc/environmen-ts
EnvironmentDecoder
cases
choice
defaultTo
index
optional
required
code:ts
const portD = required('PORT', port());
const logLevelD = pipe(
optional(
'LOG_LEVEL',
keyOf({
debug: null,
info: null,
warn: null,
error: null,
}),
),
defaultTo<LogLevel>(() => 'info'),
);
const secretKeyBaseD = required('SECRET_KEY_BASE', hex({ length: 32 }), {
// You can optionally mark a variable to be sensitive so that it will not be logged.
sensitive: true,
});
sensitive: trueをつけるとlogに出ないらしい
VariableDecoder
よくある値向けの関数が用意されている
base64
bigint
boolean
hex
host
hostname
integer
keyOf
union風
code:ts
keyOf({
debug: null,
info: null,
warn: null,
error: null,
}),
literal
natural
number
origin
port
string
url