config-type
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Configurator

Npm package

A library created with the objective to facilitate creating configuration for applications utilizing JSON (or others formats in the future). While having the security of type checking the variables and resolver to default values.

Reasong

An alternative of Convict written in Typescript, the primary reason of this library is the need of dynamically updating the configuration file in some of my projects (yeah, it has it's owns risk but I need to do it :/ and take care of all possible errors)

How to use

Setup an configuration file anywhere in your machine (be certain that the application can read the file), and use it's path in configurator

Example:

import { configurator } from "config-type";
import path from 'path';

const Configurator = configurator({
	databaseUrl: {
		description: 'Database url',
		type: 'string',
		required: true,
	},
	insert_invertal: {
		description: 'Bach insert interval used for buffer cleaning',
		type: 'number',
		required: true,
		default: 15000
	}
});

Configurator.load(path.join(__dirname, 'config.json'));

console.log(Configurator.get('databaseUrl'));

Todo

  • [X] Ability to the user add new types
  • [ ] Method that permit changing an config
  • [ ] Updating the configuration file
  • [ ] Implementing unit test's

Inspiration

Readme

Keywords

none

Package Sidebar

Install

npm i config-type

Weekly Downloads

4

Version

0.1.2

License

MIT

Unpacked Size

8.97 kB

Total Files

22

Last publish

Collaborators

  • phaalonso