Sails hook passport Sails hook passport express express

Sails hook passport


If I understand correctly, you need to init passport.js in your middleware but want to avoid having to manually edit http.js in each of your projects. To do that you'd create an installable hook like so:

module.exports = function passware(sails) {sails.config.http.middleware = {    passportInit    : require('passport').initialize(),    passportSession : require('passport').session(),    order: [      'startRequestTimer',      'cookieParser',      'session',      'passportInit',      'passportSession',      'myRequestLogger',      'bodyParser',      'handleBodyParserError',      'compress',      'methodOverride',      'poweredBy',      'router',      'www',      'favicon',      '404',      '500'    ]  }  return {};}

To use it you simply copy the hook into your node_modules or npm publish and npm install it in your projects.