Configuration framework to help manage complex application configurations in Node.js.
The Spur Framework is a collection of commonly used Node.JS libraries used to create common application types with shared libraries.
Visit NPMJS.org for a full list of Spur Framework libraries >>
Standalone:
$ npm install spur-config --save
With dependency injection:
$ npm install spur-ioc --save
$ npm install spur-common --save
$ npm install spur-config --save
Supports active Node versions in the LTS Schedule. (view current versions)
module.exports = function () {
return this.properties({
environment: 'default',
port: 8080
});
}
module.exports = function () {
return this.properties({
shared: {
someProp: 123
}
});
}
module.exports = function () {
this.extends('default');
return this.properties({
environment: 'default'
});
}
module.exports = function () {
// Extend multiple files
this.extends('default', 'shared-deployed');
return this.properties({
environment: 'production',
port: process.env.PORT or 9000
});
}
This example shows how to manually load configuration into
const spurConfig = require('spur-config');
const configDirectory = path.join(__dirname, 'src/config');
// load specific environment file
const config = SpurConfig.load(configDirectory, 'production');
// loads configuration specified in NODE_ENV environment variable
const config = SpurConfig.load(configDirectory);
This example loads the configuration into an injector/module and makes it available as the config
dependency.
const spur = require('spur-ioc');
const spurConfig = require('spur-config');
const registerConfig = require('spur-common/registerConfig');
module.exports = function () {
const ioc = spur.create('test-application');
const configDirectory = path.join(__dirname, './config');
registerConfig(ioc, configDirectory);
return ioc;
}
module.exports = function (config) {
console.log(config);
}
Please send in pull requests and they will be reviewed in a timely manner. Please review this generic guide to submitting a good pull requests. The only things we ask in addition are the following:
- Please submit small pull requests
- Provide a good description of the changes
- Code changes must include tests
- Be nice to each other in comments. 😇
The majority of the settings are controlled using an EditorConfig configuration file. To use it please download a plugin for your editor of choice.
In addition we use ESLint to enforce some of the JavaScript rules. To enable on your editor, please install one of the editor plugins.
If your editor does not have ESLint integration, the test commands below will run them and fail your build.
Execute the following the install the dependencies, build and test with the following.
$ npm install
$ npm test
View the package.json
's scripts
section for a list of all the other commands.