Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
conf.js allows you to get per-user and per-project configuration files out of the box.
Look how easy it is to use:
# settings.coffee
path = require('path')
ConfJS = require('conf.js')
module.exports = new ConfJS
userConfig: path.join(process.env.HOME, '.myprojectrc.json')
localConfig: '.myprojectrc.json'
default:
# Your usual application settings
port: '9999'
name: 'My cool app!'
...
Now if $HOME/.myprojecrc
exists, it's settings will override the defaults.
If then create a .myprojecrc
file inside one of your projects directory and run the application from within that directory, the contents will override $HOME/.myprojecrc
and defaults.
Notice that you can set a custom local configuration file within your user configuration and it'll be correctly used.
You can now get
/set
your settings with:
settings = require('./settings')
settings.get('port') # 9999
settings.set('name', 'My really cool app!')
Specify userConfig
to the user configuration file path.
Specify localConfig
to the local configuration file name.
Install conf.js by running:
$ npm install --save conf.js
Create an instance of settings.
The following options are accepted:
parse
: The function used to parse inputs (defaults to JSON.parse
).encoding
: The encoding to be used when reading files (defaults to utf8
).default
: Default settings.userConfig
: The user config file path.localConfig
: The user local file name.Extend setting with the contents of a file.
Set runtime value of a setting, or create a new one.
Notice you can set nested keys:
settings.set('my.nested.key', 'value')
Get the value of a setting.
Notice you can get nested keys:
settings.get('my.nested.key')
If you pass no key to settings.get()
, then you will get back all the settings.
Check if settings has a specific key.
Extend settings with object/s.
Check if settings object is empty.
Parse input given a function passed to options.parse
.
Run the test suite by doing:
$ gulp test
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:
$ gulp lint
If you are having any problem, please raise an issue.
get()
function returns all settings if no key.The project is licensed under the MIT license.
FAQs
Support per-user and per-project configuration files out of the box
The npm package conf.js receives a total of 7 weekly downloads. As such, conf.js popularity was classified as not popular.
We found that conf.js 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.