
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Library to configure node apps. At its core uses DemocracyOS/config but with sane defaults.
Keep your default configs on config/defaults.json
, override them with config/{NODE_ENV}.json
or with environment variables.
1 · Install it: npm install --save dos-config
2 · Run the command: ./node_modules/.bin/dos-config-init
. It will create the folder config
with the most basic defaults.
3 · Profit 🙌
var config = require('dos-config')
if (config.port) {
console.log(`The server should run at port ${config.port}. Go code it now.`)
}
First of all, dos-config
will look for the config/defaults.json
file, which will define the configuration structure with the default values.
Here's a complete example, keep in mind that the keys of your json files should always be camelCase
:
{
"port": 3000,
"mongoUrl": "mongodb://localhost/DemocracyOS-dev",
"staff": [
"some@example.com",
"another@example.com"
],
"connectionData": {},
"auth": {
"user": "Fring",
"password": "always-be-secure-123!$"
}
}
Integer
or String
. Which work as expected.Array
values can only have String
s inside.{}
means that it doesn't have a default value, but can be overriden by absolutely any JSON.After defining your defaults
, you can override them using another json file on your current environment. For example, if you are on your development machine, create config/development.json
and add there only the values you want to change (always remember to .gitignore this file!):
{
"port": 8888,
"connectionData": {
"domain": "localhost",
"port": 27099,
"user": "root"
}
}
Excellent! Now you only need to configure your production server.
You have two options; first, do the same as development, but create the file config/production.json
on your server, and make sure the NODE_ENV
environment variable is set to production
.
The other and recommended option for production, is to use environment variables. Here's an example of all the variables you should set to override the previous example:
PORT=8080
MONGO_URL='mongodb://user:pass@mongoserver/DemocracyOS-production'
STAFF=some@example.com,another@example.com
CONNECTION_DATA='{"domain": "127.123.123.123", "port": 3412}'
AUTH_USER='Admin'
AUTH_PASSWORD='some-production-password'
camelCase
to CONSTANT_CASE
._
, for example from auth.user
as AUTH_USER
.Array
s should be divided by commas ,
You can only configure the default location of your config
folder setting the environment variable CONFIG_PATH
, e.g: CONFIG_PATH=/usr/src/config
. On that folder it will look for the defaults.json
and optionally for the {NODE_ENV}.json
.
If you want something more flexible, just use https://github.com/DemocracyOS/config
FAQs
Singleton variant of DemocracyOS/config
We found that dos-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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.