
Security News
Socket Integrates With Bun 1.3’s Security Scanner API
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
server-config
Advanced tools
Load Configuration for Servers from Environment Variables, Config Files, EC2 Meta Data, etc
One of the fundamental problems of software development is keeping configuration information for different environments. Most organizations distinguish environments such as DEV, QA, Staging, and Production.
The configuration approach promoted by this little utility makes it uncesseary to keep an elaborate build process supporting these different enviroments. Using this utility, configuration information can be stored in embedded defaults that can be overriden using a configuration file and environment variables.
var path = require('path'),
loadConfig = require('server-config'),
ec2instance = loadConfig.ec2instance,
embedded = {
"httpPort": 80,
"httpsPort": 443,
"seaPort": 9090
},
host = '~/.defaults.json#myapp',
env = {
mongdb: process.env["MONGODB"],
seaPort: process.env["SEA_PORT"]
},
ec2 = {
"public-hostname":ec2instance("meta-data/public-hostname"),
"hostname":ec2instance("meta-data/hostname")
};
loadConfig(embedded, host, env, ec2, function(err, config) {
if (err) {
throw err();
}
});
Let's further assume the host
file contains:
{
"myapp": {
"httpPort": 3000,
"mongodb": "mongodb://localhost/testbase",
"welcomeMsg: "Hellow World!"
}
}
Lastly, let's assume that there is one evnironment variable defined:
export SEA_PORT=2000
If all this is the case, the resulting config information returned by the call above would be:
{
"httpPort": 3000,
"httpsPort": 443,
"welcomeMsg: "Hellow World!",
"seaPort": 2000
}
FAQs
Load Configuration for Servers from Environment Variables, Config Files, EC2 Meta Data, etc
The npm package server-config receives a total of 10 weekly downloads. As such, server-config popularity was classified as not popular.
We found that server-config 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.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.
Security News
Former RubyGems maintainers have launched The Gem Cooperative, a new community-run project aimed at rebuilding open governance in the Ruby ecosystem.