Socket
Book a DemoInstallSign in
Socket

capulet

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capulet

With capulet, you parse a configuration object from an array of required fields followed by any number of object sources.

0.1.3
latest
npmnpm
Version published
Maintainers
1
Created
Source

With capulet, you parse a configuration object from an array of required fields followed by any number of object sources.

If any key is missing after merging the object sources, capulet will throw. If you want a key to be optional, you should supply a default value object somewhere in the chain (that value can be undefined or null).

The new config object is populated by merging in objects left to right (like Object.assign or _.merge). Any defaults should be added first, and then the user configuration source.


const capulet = require('capulet');

const config = capulet([
	'db',
	'templateDirectory',
], {
	'db': 'mongodb://localhost:27017/mydb',
}, process.env);

const db = config.get('db');

The config exposes a middleware function for use with connect/express, that exposes the get method as config on the request object.

const express = require('express');
const app = express();

app.use(config.middleware());

app.use(function (req, res) {
	const db = req.config('db');
	const entireConfig = req.config();
});

FAQs

Package last updated on 16 Jan 2017

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.