Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

config-typing

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

config-typing

An config loader with type checking and resolver to defaults values

  • 0.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

Config validator

Npm package

Warning

This package was renamed to config-validation

A library created with the objective to facilitate creating configurating configuration that are stored in JSON files. It's uses a schema defined by the user, that the loaded json file needs to have otherside the loading of the file will fail as an "Config error".

Important

In the moment this library is in pre-release, so be careful when to use it. There can be lots of bugs or some problems that needs to be fixed.

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,
	},
	server: {
		port: {
			description: 'The server port',
			type: 'number',
			default: 3333,
		}
	}
});

// Load configs from the file config.json
Configurator.load(path.join(__dirname, 'config.json'));

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

// Update the config value
Configurator.set('databaseUrl', 'Another url')

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

// Write the config changes to the file
Configurator.updateConfigFile();

Todo

  • Ability to the user add new types
  • Method that permit changing an config
  • Updating the configuration file
  • Sub-configs
  • Fix set and get to work with Sub-configs
  • Implementing unit test's

Inspiration

  • Convict

FAQs

Package last updated on 17 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc