0.10.5 • Published 10 years ago

sails-inject v0.10.5

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

-inject

NPM version Build status Dependency Status

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)

@paramdescription
options.sailsglobal sails object
options.modulereference to the main module.id of the sails app to inject
options.connectionoptional connection to use for the injected models

.injectModels(options, next)

@paramdescription
options.sailsglobal sails object
options.modelslist of models in the form { definition: Object, globalId: String }
options.connectionoptional connection to use for the injected models

License

MIT

Attribution

Much of this implementation is adapted from: