npm.io
0.10.5 • Published 12 years ago

sails-inject

Licence
MIT
Version
0.10.5
Deps
3
Vulns
5
Weekly
0
Stars
7

-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)

| @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:

Keywords