Adding express middleware to the sails application is simple.
create a new policy.
policies |_ middleware.js / .coffee
Add Express Middleware YOUR_MIDDLE_WARE_FILE_NAME.js
Inside your intermediate file, we create a standard export for node.js
module.exports = require('middle-ware')(OPTIONS_GO_HERE) // See middleware docs for configuration settings.
Then, once you have created the middleware, you can apply it to all requests or to one controller, following the Sails.js content.
Integrated policies.js application
module.exports.policies = { '*':['middleware']
The action of one controller policies.js
module.exports.policies = { RabbitController:{ feed:['middleware'] } }
jqualls
source share