https://github.com/yurijmikhalevich/cat-settings
Simple settings module for node.js, providing simple API to access and modify application settings, stored in JSON-file
https://github.com/yurijmikhalevich/cat-settings
cat-settings javascript json settings
Last synced: about 1 year ago
JSON representation
Simple settings module for node.js, providing simple API to access and modify application settings, stored in JSON-file
- Host: GitHub
- URL: https://github.com/yurijmikhalevich/cat-settings
- Owner: yurijmikhalevich
- License: other
- Created: 2013-05-16T06:07:08.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2014-07-30T17:23:33.000Z (almost 12 years ago)
- Last Synced: 2025-05-09T01:12:19.510Z (about 1 year ago)
- Topics: cat-settings, javascript, json, settings
- Language: JavaScript
- Homepage: https://npmjs.org/package/cat-settings
- Size: 194 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cat-settings
Simple settings module for node.js, providing simple API to access and modify application settings, stored in JSON-file.
Uses jsonfile module.
JSON-file should store an object.
Installation:
```bash
$ npm install cat-settings
```
Example:
```javascript
var settings = require('cat-settings').loadSync(__dirname + '/settings.json');
// You may also use async load if it makes sense
settings.load(null, function(err) {
if (err) {
// ...
}
});
app.set('port', settings.app.port);
// ...
settings.cat = {};
settings.cat.name = 'Leopold';
settings.saveSync();
// You may also use async save if it makes sense
settings.save(null, function(err) {
if (err) {
// ...
}
});
```
When you pass file argument to load or save methods, you also change file, where settings are stored, in most cases
you should pass it only when you call load first time.
After, you can require cat-settings whenever you want and access parameters, without calling load.