Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@allohamora/config-manager

allohamora43MIT0.9.0TypeScript support: included

config manager

config, config-manager, config-service, service, utils, env, type-safe, zero, dependencies

readme

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

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.9.0 (2023-09-12)

Features

0.8.2 (2023-09-07)

Bug Fixes

  • fix incorrect return types for orThrow methods (504dda4)

0.8.1 (2023-09-06)

Features

  • regenerate CHANGELOG.md (2e3ca7e)

0.8.0 (2023-09-06)

Features

  • add return types and remove unnecessary as casting (642ccde)
  • improve defaultFor response types (7726b0f)
  • improve EnvPicker types (4893b92)
  • remove env.manager cache (def7154)

0.7.0 (2023-07-27)

Features

  • add rest to envRecord (2d57b5d)
  • improve defaultFor with rest return value (304530d)
  • improve orThrow methods typing (d7f7590)

0.6.0 (2023-04-13)

⚠ BREAKING CHANGES

  • replace load method with get + type

Features

  • replace load method with get + type (3c2a8c2)

0.5.2 (2023-04-11)

Features

0.5.1 (2023-04-11)

Features

  • update README.md to fix missing README.md in npm (666dcaf)

0.5.0 (2023-04-11)

⚠ BREAKING CHANGES

  • pickFor now every time returns EnvPicker

Features

  • pickFor now every time returns EnvPicker (e688443)

0.4.0 (2023-04-10)

Features

  • add atLeastOne to for methods (1b43a5f)
  • add EnvPicker export (9d03bc8)
  • add getFor and getForOrThrow (51dbf8c)
  • add pickFor and pickForOrThrow (689b5ba)
  • improve nodeEnv typings (3673a1d)

Bug Fixes

  • rename mapIfExist to mapIfExists (2d1c8e4)

0.3.0 (2023-04-08)

Features

  • add support for not plain objects (a45151f)

0.2.2 (2023-04-08)

Features

0.2.1 (2023-04-08)

Features

0.2.0 (2023-04-08)

Features

  • add env-manager and env-picker (30e2dcb)
  • add mapIfExist to env-picker (f40413c)
  • add null or undefined check to getOrThrow (66da1ee)
  • add trim to pickOrThrow (ff16658)
  • improve env-picker default typings (39fefc8)

Bug Fixes

  • add correct typing to manager methods (f05bbae)
  • fix incorrect default value changing (57aa7a0)

0.1.2 (2023-03-28)

Bug Fixes

0.1.1 (2023-03-17)

Bug Fixes

  • add private modifier to config field (10f038d)

0.1.0 (2023-03-07)

Features

0.0.1 (2023-03-07)

Features