npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

configchecker

v1.5.84

Published

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

Downloads

414

Readme

☑️ Config Checker

NPM Version of Config Checker Quality of package Config Checker Known Vulnerabilities Issues Socket

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

Wallpaper of ☑️ Config Checker

Install

Install from NPM

npm i configchecker

💡 Motivation

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 tries to send some email. Maybe it drops the whole server or just don't do nothing and you will be figuring out why the hell server is working but it doesn't 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 '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 '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 like sample 1 but unfortunately it is not using full TypeScript potential.

import { ConfigChecker } from 'configchecker';
const config = ConfigChecker.from(process.env);

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

Authors

🖋️ Contributing

I am open to pull requests, feedback, and suggestions. Or if you like this utility, you can ☕ buy me a coffee or donate via cryptocurrencies.

You can also ⭐ star the configchecker package, follow me on GitHub or various other social networks.

✨ Partners

           

Become a partner