Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
feathers-configuration
Advanced tools
A small configuration module for your Feathers application.
feathers-configuration
allows you to load default and environment specific JSON configuration files and environment variables and set them on your application. Here is what it does:
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 it an absolute path relative to the configuration file pathThe 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(__dirname, 'settings'))
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 app = feathers()
.configure(configuration(__dirname));
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'));
If you now run
node app
// -> path/to/app/public
// -> localhost
// -> 3030
// -> mongodb://localhost:27017/myapp
// -> path/to/templates
Or with a different environment and variables:
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
0.1.0
Copyright (c) 2015
Licensed under the MIT license.
v0.2.1 (2016-03-12)
Merged pull requests:
FAQs
A small configuration module for your Feathers application.
The npm package feathers-configuration receives a total of 379 weekly downloads. As such, feathers-configuration popularity was classified as not popular.
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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.