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

configchecker

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configchecker

Awesome checker of config - fully support typescript, fluent API,...

  • 0.5.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Config Checker

A very simple and effective way to check config, before it's used in runtime with nice fluent API.

Install

Install from NPM

npm i configchecker

Story

When you use some ENV value do you really know what it contains or if it is really defined?

export const { TESTING_MAIL } = process.env;

This will be OK until your server tryis to send some email. Maybe it drop whole server or just dont do nothing and you will be figuring out why the hell server is working but it dont send any emails.

I have this problem many many times.

And because I am a TypeScript lover it is fully using all advantages of static typing.

Usage

I load the config from some environment Object:

import { ConfigChecker } from '../src/classes/ConfigChecker';

const config = ConfigChecker.from(process.env);

And then I can read variabiles from it:

config.get('TESTING_MAIL').value;

I can enforce them:

config.get('TESTING_MAIL').required().value;

I can convert them to certain types:

config.get('...').number().value;
config.get('...').boolean().value;
config.get('...').json().value;
config.get('...').list().value;
config.get('...').date().value;
config.get('...').url().value;

Full sample 1

import { ConfigChecker } from '../src/classes/ConfigChecker';
const config = ConfigChecker.from(process.env);

export const PORT = config.get('PORT').number().required().value;
export const TESTING_MAIL = config.get('TESTING_MAIL').value;

Full sample 2

This sample is working same as sample 1 but unfortunatelly it is not using full TypeScript potencial.

import { ConfigChecker } from '../src/classes/ConfigChecker';
const config = ConfigChecker.from(process.env);

export default {
    ...config.get('PORT').number().required().object,
    ...config.get('TESTING_MAIL').object
}

Contributing

I am opened to your pull requests, feedback, suggestions and donations :) . Contact to me are on my personal page

Authors

Thanks

To boilerplate was used my-awesome-greeter.

FAQs

Package last updated on 30 Jun 2019

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