A super straightforward dependency injection library for Node.js, inspired by AngularJS and the Java Spring Framework.
Example Project Layout
- src
- App.js
- Config.js
- util
- Decorator.js
- index.js
- sorcerer.config.js
/src/App.js
// all files in the provided directory use this general formatmodule{ var app = {}; console; return app;}
/src/Config.js
moduleexports = whateverYouWantHere: 'yeah'
/src/util/Decorator.js
module{ // this will evaluate since it is referencing an active resource Appname = 'Decorated App';}
/sorcerer.config.js
moduleexports = basePath: __dirname // default: execution directory verbose: true // default: false (you can use strings/arrays to allow verbosity in specific environments) packages: env: 'production' // use specified env (process.env.NODE_ENV by default) path: '/src' // you can also just pass the path string instead of a config object name: 'globals' // optional include: // note that you can use both `path` and `include` in the same package 'Some example resource' ;
/index.js
// simple example (no config object)__dirname + '/src' 'App'; // using externalized configvar config = ; // configure a directoryconfig { // You can use any file as an entry point console;}; // or, configure a directory with a specified environmentconfig 'test' { console;}; // or, configure a directory with error handlingconfig { iferr return console; console;};