@allohamora/config-manager
TypeScript icon, indicating that this package has built-in type declarations

0.9.0 • Public • Published

Config-Manager

npm build test release

This package contains managers and utils for creating configs in a type-safe and stylish way.

Requirements

{
  "node": ">=18.14.0",
  "npm": ">=9.3.1"
}

Install

npm i @allohamora/config-manager

Usage

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.9.0
    49
    • latest

Version History

Package Sidebar

Install

npm i @allohamora/config-manager

Weekly Downloads

49

Version

0.9.0

License

MIT

Unpacked Size

47.9 kB

Total Files

10

Last publish

Collaborators

  • allohamora