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

configs

v1.0.3

Published

Super simple project configuration

Downloads

748

Readme

Configs

Build Status devDependency Status NPM version

Zero configuration config module. Simply require the module and your project's config files will be loaded and merged together.

A default configuration file is looked for and loaded first, followed by an environment level config file, based on NODE_ENV. Lastly a local config file is loaded. All configuration files are recursively extended into any previously loaded file.

Both .js and .json extentions will be loaded.

The local file is the last on the list to give you the flexibility of having per user configs, this file is generally included in your .gitignore to provide flexibility on the end developer. This could also be used as part of a deployment strategy if you don't want to rely on NODE_ENV based settings. Simply copy or
move the file you want, lets say config/production.json, into config/local.json to ensure the correct app configuration reguardless of your environment variables.

Why?

There are plenty of other configuration modules out there, so why another one? I wanted a config module that I didn't have to configure, with many others you will end up including the module, telling it where your files live, and / or providing it defaults. You might just end up with a config.js file as a wrapper to the module of your choosing, too much work I say! This is meant to be an extremely simple way of configuring your app, all while having a local config in mind, which can be very useful when a team is working on the same project.

Usage

var config = require('configs')

Config files will be be loaded with the following pattern, pathing is relative to the project root directory. The project root directory is found by following the module.parent recursively until there either is no more parents or a package.json file is found.

Directory based:

  • ./config/default.json
  • ./config/{NODE_ENV}.json
  • ./config/local.json

File based:

  • ./config.json
  • ./config.local.json
  • ./config.{NODE_ENV}.json

Example

Seperate file configurations

In ./config/default.json:

{
  "debug": false
, "database": {
    "host": "localhost"
  , "port": 6379
  , "user": "paul"
  }
}

In ./config/local.json:

{
  "debug": true
, "database": {
    "port": 11212
  }
}

End result: require('configs')

{
  "debug": true
, "database": {
    "host": "localhost"
  , "port": 11212
  , "user": "paul"
  }
}

Single file configuration

If only a single configuration file is found, the module will check for a property matching the current NODE_ENV and extend it into the base config.

In ./config.json

{
  "something": true
, "sea": {
    "lab": 2021
  }
, "production": {
    "something": false
  , "hey": "there"
  }
}

With NODE_ENV=production, require('configs')

  "something": false
, "hey": "there"
, "sea": {
    "lab": 2021
  }
, "production": {
    "something": false
  , "hey": "there"
  }
}

Debug

If a debug property is found after all files have been loaded, the module will output the file paths of everything that was loaded.

package.json

If a package.json is found within the root directory, the version property will be added to the config. The module will also check for a config property that can be used to specify the directory in which the files are located. Defaults to ./config

Install

With npm

npm install configs

License

(The MIT License)

Copyright (c) 2011-2012 Beau Sorensen [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.