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

node-config-service

v1.9.0

Published

A config management service for your next node app.

Downloads

9

Readme

Simple config config management for node apps.

npm GitHub all releases GitHub issues GitHub last commit

NPM

const nodeConfigService = require('node-config-service');

console.log(process.env);

About

Keywords

NodeConfigService is a node module used to manage a set of config variables that are dependent upon node environmental variables set on the server.

Merge several configuration sources into a portable get method used throughout the app.

Getting Started

Prerequisites

Before starting, download and install Node.js. Node.js 14.0 or higher is required. Git is required to contribute to the project.

Optional tools include install yarn if desired. $ npm install --global yarn

Installation

NodeConfigService is a Node.js module available through the npm and yarn package registries.

If you have not already done so, create a package.json for your project with the npm init or the yarn init command.

Including this module using the npm install or the yarn install command:

In a terminal, type :

$ npm install node-config-service --save-dev
# or
$ yarn add node-config-service --dev

Features

  • Define config params in a json file.
  • Load config variables with node env params, pass them programmatically, or load them from asynchronous sources.

Usage

Process environmental variables can be set in a number of ways including the command line interface, in the package.json and using .env files in the root of your project.

Under the hood NodeConfigService uses Dotenv to populate the node process.env object with the defined variables.

require('node-config-service');

console.log(process.env);

Dotenv-expand adds variable expansion on top of dotenv . This allows the use of simple and complex examples of variable expansion in your .env file.

Example Env Variables

NODE_ENV=development
PROPERTY_KEY=property_value
NODE_ENV=production

MONGOLAB_DATABASE=heroku_db
MONGOLAB_USER=username
MONGOLAB_PASSWORD=password
MONGOLAB_DOMAIN=abcd1234.mongolab.com
MONGOLAB_PORT=12345
MONGOLAB_URI=mongodb://${MONGOLAB_USER}:${MONGOLAB_PASSWORD}@${MONGOLAB_DOMAIN}:${MONGOLAB_PORT}/${MONGOLAB_DATABASE}
NODE_ENV=test
BASIC=basic

BASIC_EXPAND=$BASIC

MACHINE=machine_env
MACHINE_EXPAND=$MACHINE

UNDEFINED_EXPAND=$UNDEFINED_ENV_KEY

ESCAPED_EXPAND=\$ESCAPED

DEFINED_EXPAND_WITH_DEFAULT=${MACHINE:-default}
DEFINED_EXPAND_WITH_DEFAULT_NESTED=${MACHINE:-${UNDEFINED_ENV_KEY:-default}}

UNDEFINED_EXPAND_WITH_DEFINED_NESTED=${UNDEFINED_ENV_KEY:-${MACHINE:-default}}
UNDEFINED_EXPAND_WITH_DEFAULT=${UNDEFINED_ENV_KEY:-default}
UNDEFINED_EXPAND_WITH_DEFAULT_NESTED=${UNDEFINED_ENV_KEY:-${UNDEFINED_ENV_KEY_2:-default}}
UNDEFINED_EXPAND_WITH_DEFAULT_NESTED_TWICE=${UNDEFINED_ENV_KEY:-${UNDEFINED_ENV_KEY_2${UNDEFINED_ENV_KEY_3:-default}}}
UNDEFINED_EXPAND_WITH_DEFAULT_WITH_SPECIAL_CHARACTERS=${UNDEFINED_ENV_KEY:-/default/path}

MONGOLAB_DATABASE=heroku_db
MONGOLAB_USER=username
MONGOLAB_PASSWORD=password
MONGOLAB_DOMAIN=abcd1234.mongolab.com
MONGOLAB_PORT=12345
MONGOLAB_URI=mongodb://${MONGOLAB_USER}:${MONGOLAB_PASSWORD}@${MONGOLAB_DOMAIN}:${MONGOLAB_PORT}/${MONGOLAB_DATABASE}

MONGOLAB_USER_RECURSIVELY=${MONGOLAB_USER}:${MONGOLAB_PASSWORD}
MONGOLAB_URI_RECURSIVELY=mongodb://${MONGOLAB_USER_RECURSIVELY}@${MONGOLAB_DOMAIN}:${MONGOLAB_PORT}/${MONGOLAB_DATABASE}

WITHOUT_CURLY_BRACES_URI=mongodb://$MONGOLAB_USER:$MONGOLAB_PASSWORD@$MONGOLAB_DOMAIN:$MONGOLAB_PORT/$MONGOLAB_DATABASE
WITHOUT_CURLY_BRACES_USER_RECURSIVELY=$MONGOLAB_USER:$MONGOLAB_PASSWORD
WITHOUT_CURLY_BRACES_URI_RECURSIVELY=mongodb://$MONGOLAB_USER_RECURSIVELY@$MONGOLAB_DOMAIN:$MONGOLAB_PORT/$MONGOLAB_DATABASE
WITHOUT_CURLY_BRACES_UNDEFINED_EXPAND_WITH_DEFAULT_WITH_SPECIAL_CHARACTERS=$UNDEFINED_ENV_KEY:-/default/path

API Reference

NodeConfigService

NodeJS Config Service.

Simplified config management for node applications. NodeConfigService accepts a configuration object of properties to be defined using the node process env and run time overrides.

NodeConfigService.NodeConfigService#version

The NodeConfigService version

Example:

console.log(nodeConfigService.version); // '1.x.x'

Kind: static property of NodeConfigService Api: public Properties

| Name | | --- | | version |

NodeConfigService.NodeConfigService#NodeConfigService

The NodeConfigService constructor

The exports of the nodeConfigService module is an instance of this class.

Example:

const appConfig = require('nodeConfigService');
const moduleConfig = new nodeConfigService.NodeConfigService();

Kind: static property of NodeConfigService Access: public Properties

| Name | | --- | | NodeConfigService |

NodeConfigService.NodeConfigService#errors

Key and class object map of custom error methods.

Kind: static property of NodeConfigService Access: public Properties

| Name | Type | Description | | --- | --- | --- | | errors | Object | Key and class object map of custom error methods. |

NodeConfigService.module.exports : NodeConfigService

The exports object is an instance of NodeConfigService.

Kind: static property of NodeConfigService Access: public

"loadEnv"

Load environment variables into process.env using dotenv.

NOTE: Should be placed as early as possible on startup.

Kind: event emitted by NodeConfigService

Issues

If you experience unexpected behavior please let the maintainers know.

To help us quickly find and solve your problem, pease try to create bug reports that are:

  • Reproducible. Include steps to reproduce the problem.
  • Specific. Include as much detail as possible: which version, what environment, etc.
  • Unique. Do not duplicate existing opened issues.
  • Scoped to a Single Bug. One bug per report.

Development

ForTheBadge built-by-developers

Dev requirements

Scripts

To view an interactive menu of project commands, first install the dependencies, then use execute the start command using either npm or yarn

View the interactive cli tool that lists and run package.json scripts by using:

$ npm install
$ npm start
# or
$ yarn install
$ yarn start
$ ntl
√  Node Task List
? Select a task to run: (Use arrow keys)
> start
  menu
  info
  test
  format
  build
  build-docs
(Move up and down to reveal more choices)

Running Tests

To run the test suite, first install the dependencies, then run the test command:

$ npm install
$ npm test
# or
$ yarn install
$ yarn test

Contributing

First off, thanks for taking the time to contribute! Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

GitHub forks GitHub last commit GitHub watchers

Contact

If you like my work, then give me a star or follow my GitHub.

License

Freely distributed under the MIT License. Copyright © Rachel Dotey, 2021-present.