Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
feathers-configuration
Advanced tools
Changelog
v0.4.2 (2017-10-15)
Closed issues:
Merged pull requests:
Readme
A small configuration module for your Feathers application.
The v0.4.x release of feathers-configuration
is a breaking version and implementations that were made with earlier versions of the module may be required to make some minor changes. Please see the migrating section for specifics.
This module is a simple wrapper on node-config that adds a bit of convenience. By default this implementation will look in config/*
for default.json
which retains convention. As per the config docs you can organize "hierarchical configurations for your app deployments". See the usage section below for better information how to implement this.
Please note: future releases will also include the ability to define adapters which will allow you to use external configuration storage like vault or etcd.
Moving from 0.3.x to 0.4.x should be mostly backwards compatible. The main change is that instead of passing the location of your configuration into the module constructor like this:
let config = require('feathers-configuration')(root, env, deepAssign);
The module now simply inherits from NODE_ENV
and NODE_CONFIG_DIR
as per the node-config docs:
$ NODE_ENV=development NODE_CONFIG_DIR=./config/ node app.js
If you are currently setting your configurations via construction arguments, you will need to move these values out of your app into these environment variables.
With the implementation of node-config we also now have the ability to set a custom-environment-variables.json
file which will allow you to define which variables to override from process.env
. See below for examples.
The feathers-configuration
module is an app configuration function that takes a root directory (usually something like __dirname
in your application) and the configuration folder (set to config
by default):
import feathers from 'feathers';
import configuration from 'feathers-configuration';
// Use the current folder as the root and look configuration up in `settings`
let app = feathers().configure(configuration())
feathers-configuration
uses the following variable mechanisms:
default.json
in that pathNODE_ENV
is not development
, also try to load <NODE_ENV>.json
in that path and merge both configurationsapp.set(name, value)
).
NODE_ENV
), use its value instead./
or ../
turn it into an absolute path relative to the configuration file path\
) always use that value (e.g. \\NODE_ENV
will become NODE_ENV
)default
and <env>
configurations can be modules which provide their computed settings with module.exports = {...}
and a .js
file suffix. See test/config/testing.js
for an example..js
modules.In config/default.json
we want to use the local development environment and default MongoDB connection string:
{
"frontend": "../public",
"host": "localhost",
"port": 3030,
"mongodb": "mongodb://localhost:27017/myapp",
"templates": "../templates"
}
In config/production.js
we are going to use environment variables (e.g. set by Heroku) and use public/dist
to load the frontend production build:
{
"frontend": "./public/dist",
"host": "myapp.com",
"port": "PORT",
"mongodb": "MONGOHQ_URL"
}
Now it can be used in our app.js
like this:
import feathers from 'feathers';
import configuration from 'feathers-configuration';
let conf = configuration();
let app = feathers()
.configure(conf);
console.log(app.get('frontend'));
console.log(app.get('host'));
console.log(app.get('port'));
console.log(app.get('mongodb'));
console.log(app.get('templates'));
console.log(conf());
If you now run
node app
// -> path/to/app/public
// -> localhost
// -> 3030
// -> mongodb://localhost:27017/myapp
// -> path/to/templates
Or via custom environment variables by setting them in config/custom-environment-variables.json
:
{
"port": "PORT",
"mongodb": "MONGOHQ_URL"
}
$ PORT=8080 MONGOHQ_URL=mongodb://localhost:27017/production NODE_ENV=production node app
// -> path/to/app/public/dist
// -> myapp.com
// -> 8080
// -> mongodb://localhost:27017/production
// -> path/to/templates
You can also override these variables with arguments. Read more about how with node-config
Copyright (c) 2015
Licensed under the MIT license.
FAQs
A small configuration module for your Feathers application.
We found that feathers-configuration demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).