sails-inject
v0.10.5
Published
Inject additional models, controllers, etc. into a sails.js from a hook. Extends a sails.js app by injecting another sails.js app into it
Downloads
6
Maintainers
Readme
-inject
Inject additional models, controllers, etc. into a sails.js from a hook. Extends a sails.js app by injecting another sails.js app into it
Install
$ npm install sails-inject --save
Usage
e.g. with sails-permissions:
// api/hooks/myHook.js
var injector = require('sails-inject');
injector.injectApp({
sails: sails,
module: module.id
}, next);
The additional models be initialized and available in the global namespace per usual.
API
.injectApp(options, next)
| @param | description |
|:---|:---|:---|
| options.sails
| global sails object |
| options.module
| reference to the main module.id
of the sails app to inject
| options.connection
| optional connection to use for the injected models
.injectModels(options, next)
| @param | description |
|:---|:---|:---|
| options.sails
| global sails object |
| options.models
| list of models in the form { definition: Object, globalId: String }
| options.connection
| optional connection to use for the injected models
License
MIT
Attribution
Much of this implementation is adapted from: