Create Settings
Typesafe and lightweight tool for working with settings
Installation
npm i create-settings# or yarn add create-settings
Problem
You need configurable module that will be configured in runtime with different values those depend on environment, you want it to be typesafe, lightweight and easy to use,
Usage
; const settings = ; // variant 1settings ; // variant 2 { configurator;} settings;
API
createSettings(defaultSettings)
Create new settings object
Options:
Name | Type | Description | Default |
---|---|---|---|
defaultSettings | [setting: string]: any |
Array of AxiosLayer, this is the only required option | none |
Settings.configure
Configure settings object, you can provide function for configuration, or configure it inline i.e.
settings ;
Settings.configureAsync
The same as configure but works with Promise API
Testing
-
You can create factory and call that in tests
const createUserSettings =and in each test create it with needed values,
-
You can just export settings object and in test reset it in beforeEach hook
Library export ExtractSettingsObject
helper type in case when you need to get type of settings object itself
Licence
MIT