
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
npm install configr
It allows you to parse and merge multiple JSON configuration files (allowing you to create environment specific configuration) and then access your configuration through a simple interface.
Your applications configuration takes the form of simple JSON files. You create a directory to store your config files, the config files stored in the root are merged and form the 'base' configuration that is shares between all environments.
To create environment specific overrides you create sub directories, for each environment, and place the configuration files in the there for each environment. For example, you start off with a config dir, and in there you have 'general.js' and 'db.js' files. See below
// general.js
module.exports = {
"app_name" : "test_app",
"hawtness" : "extreme"
}
// db.js
module.exports = {
"host" : "127.0.0.1",
"user" : "myuser",
"pass" : "mypass",
"db" : "mydb"
}
These files are merged into an internal structure:
{
"general" : {
"app_name" : "test_app",
"hawtness" : "extreme"
},
"db" : {
"host" : "127.0.0.1",
"user" : "myuser",
"pass" : "mypass",
"db" : "mydb"
}
}
You can then create environment specific config overrides; let's create a dev environment; create a folder called 'dev' in the config dir, and we add a db.js file with specific overrides for the dev environment.
module.exports = {
"host" : "dev.db.com",
"user" : "devuser",
"pass" : "devpass"
}
When you create a configr instance (as shown below) the internal structure will be as follows:
{
"general" : {
"app_name" : "test_app",
"hawtness" : "extreme"
},
"db" : {
"host" : "dev.db.com", // Overriden
"user" : "devuser", // Overriden
"pass" : "devpass", // Overriden
"db" : "mydb"
}
}
// Create a new configr instance for the provided environment. This is any arbitary name;
// dev, staging, prod, etc. (you can have multiple configr instances that are independant
// of one another).
var Configr = require("configr");
var c = new Configr('/path/to/config/files');
// Load the configuration
// Access the configuration values
c.get().db // will return { "host" : "127.0.0.1", "user" : "myuser", "pass" : "mypass", "db" : "mydb"}
c.get().general.app_name // will return "test_app"
// Load the configuration for the dev environment
var c = new Configr('/path/to/config/files','dev');
// Access the configuration values
c.get().db // will return { "host" : "dev.db.com", "user" : "devuser", "pass" : "devpass", "db" : "mydb"}
c.get().general.app_name // will return "test_app"
FAQs
A library parse JSON configuration files.
The npm package configr receives a total of 0 weekly downloads. As such, configr popularity was classified as not popular.
We found that configr 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 now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.