This package contains managers and utils for creating configs in a type-safe and stylish way.
{
"node": ">=18.14.0",
"npm": ">=9.3.1"
}
npm i @allohamora/config-manager
import { ConfigManager, EnvManager } from '@allohamora/config-manager';
const env = new EnvManager();
const config = new ConfigManager({
getConfig: () => ({
auth: {
email: env.pick('AUTH_EMAIL').default('example@example.com').value(), // string
password: env.get('AUTH_PASSWORD'), // string | undefined,
},
}),
});
config.getOrThrow('auth'); // { email: string, password?: string }
config.get('auth.email'); // string
config.get('auth.password'); // string | undefined
config.getOrThrow('auth.password'); // string or the validation error