New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

confess

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

confess

A configuration wrapper around the configuration manager `convict`

  • 1.0.1
  • Source
  • npm
  • Socket score

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

confess

io.js compatibility node.js compatibility

NPM version Dependency Status Dev Dependency Status Code Climate Build Status Coverage Status

confess is a configuration wrapper around convict.

The problem

Setting up configuration and using configuration seem to be two different concerns approached by other configuration modules. Convict is a module that has (in my opinion) done a really good job at setting up configuration. It's extensible, easy to integrate with in any system, and can be customized to do just about anything the other configuration loaders can do. Using it, though, can be a pain. You create a config.js or config/index.js or something that loads convict and configures your configuration. That's the good part. But when you want to use your configuration, it's only available if you require() it from wherever you are in your file system, which could requires a lot of ../.

This module makes abstracts my most common use cases of setting up configuration with convict, with the convenience of use a require without paths.

Installation

npm install --save confess

Usage

In the root of your project create a folder called config/.

In this folder, there will be 3 classes of files:

  • Schema definition file - This is the file that defines the schema of the main configuration options. This file should export an object that you would use to define your convict configuration. Documentation on how to set up the schema can be found here. The default name for this file is index.js.

  • Default configuration file - This file gets loaded and merged into the config object using convict's .load() method. The default name for this file is default.js.

  • Environment configuration files - The default schema that gets loaded includes and environment configuration that you can set with an environment variable (NODE_ENV) or with a flag (--env). The default environment is development so it loads development.js. It is recommended that you create multiple environment configuration files, such as test and production. Any configuration options set in these files with override those in default and the schema defaults.

The object that gets returned is the convict config object. So to get a config value, just use it like you would in convict.

'use strict';

var config = require('confess');

config.get('port');
config.get('session.secret');

For more documentation on things you can do with the convict config object, see their documentation;

Configuration

You can override things like the folder and schema filename by putting a .confessrc file in the root of your project.

{
  "extension": "js", // can be js or json
  "schemaPrefix": "index",
  "defaultPrefix": "default",
  "defaultEnv": "development",
  "configDir": "config", // relative dir to cwd
  "cwd": "" // This defaults to what process.cwd() is
}

If anyone would like to add more file extension support, submit an issue or pull request. I stuck with just js and json because this is nodejs/iojs.

Examples

To view example folder/file structures, view the examples directory.

Keywords

FAQs

Package last updated on 23 Jul 2015

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