
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
A simple configuration management module used for node projects.
$ npm install configly --save
var config = require('configly');
Create a directory in the root of your project called config.
Every .js and .json in that directory will be included in the config object
returned.
For example: if you create a file called lib.json with these contents...
{
"foo": "bar"
}
...the final config object will look like this...
{
lib: {
foo: 'bar'
}
}
If you use a .js file instead of a .json file, then you just need to make
sure you put stuff in the module.exports object. The above example in .js
form...
module.exports = {
lib: {
foo: 'bar
}
};
If you have a multi-word filename, only use dashes and underscores to separate the words. This is because the filename is converted to camelCase.
For example: if you create a file called user-permissions.json with these
content...
{
"/": [
"anonymous",
"admin"
],
"/admin": [
"admin"
]
}
...the final config object will look like this...
{
userPermissions: {
'/': [
'anonymous',
'admin'
],
'/admin': [
'admin'
]
}
}
To signify that a config file is an environment config file, use this naming convention:
env.[environment name].js(on)
The environment name should be the name of the environment you want the config
file to be for.
For example, if it's for a development environment, you should name the config
file env.development.json or env.development.js.
To change the environment used, you just need to specify the NODE_ENV variable
when running your app. E.g. NODE_ENV=production node app
If no NODE_ENV variable is provided, it will default to development, so you
should always have an env.development.json file
Although you can a config file with the same name but have different extentions
(i.e. .js and .json), you shouldn't because one of them will not be
included. From the tests that I've done, it takes the .json version because
it shows up later in the list. At any rate, it seems like it would be bad
practice to have two files with the same name in the same directory.
Your config directory has to be where your process.cwd() resides. In the
future, I would like this to be configurable, but in the spirit of quick
iterations and getting feedback, I will save that for another day.
FAQs
A developer-friendly lightweight replacement for the 'config' module that works with custom config directories and pluggable parsers
We found that configly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.