Skip to content

Latest commit

 

History

History
55 lines (37 loc) · 1.18 KB

MIGRATING.md

File metadata and controls

55 lines (37 loc) · 1.18 KB

Migration Guide

Migrating from 2.x to 3.x

This only applies if you use Typescript. The generics definitions have changed.

You can now define an interface for your settings and it will be recognized via autocompletion.

If you use generics with the CerebroConfig API, you will need to update your generics to match the new definitions.

This would apply to the following methods:

  getRawValue()
  isEnabled()
  getValue()
  getAssertValue()
  getRawConfig()

Before:

const value = config.isEnabled<boolean>('enable_database')

After (static config)

import { loadStaticConfig } from 'configurity'

interface Settings {
  enable_database: boolean
}

const config = loadStaticConfig<Settings>('example.yaml')

// No need for the generic anymore, it should be inferred
const databaseEnabled = config.isEnabled('enable_database')

After (dynamic config)

import { loadDynamicConfig } from 'configurity'

interface Settings {
  enable_database: boolean
}

const config = loadDynamicConfig<Settings>('example.yaml')

// No need for the generic anymore, it should be inferred
const databaseEnabled = config.isEnabled('enable_database')