Loading all strategies via require significantly slows down an application. Should only load those strategies needed by an application. I've had to modify the source code to do this in my app. As follows:
this.map = {
facebook: ['passport-facebook','Strategy'],
twitter: ['passport-twitter','Strategy'],
instagram: ['passport-instagram','Strategy'],
linkedin: ['passport-linkedin','Strategy'],
github: ['passport-github','Strategy'],
google: ['passport-google-oauth','OAuth2Strategy'],
amazon: ['passport-amazon','Strategy'],
dropbox: ['passport-dropbox-oauth2','Strategy'],
foursquare: ['passport-foursquare','Strategy'],
imgur: ['passport-imgur','Strategy'],
meetup: ['passport-meetup','Strategy'],
wordpress: ['passport-wordpress','Strategy'],
tumblr: ['passport-tumblr','Strategy']
};
and then require them at:
var theStrategy = require(this.map[type][0])[this.map[type][1]];
// Execute the passport strategy
//passport.use(new (this.map[type])(passportSetup, settings.methods.auth));
passport.use(new (theStrategy)(passportSetup, function (req, accessToken, refreshToken, profile, done) {
scope.onAuth(req, type, scope.uniqueIds[type], accessToken, refreshToken, scope.returnRaw?profile:scope.preparseProfileData(type, profile), done);
}));
Needed to use an array in this.map because I can't be sure that the 'Strategy' object will be called 'Strategy' (see google OAuth2)
Loading all strategies via require significantly slows down an application. Should only load those strategies needed by an application. I've had to modify the source code to do this in my app. As follows:
and then require them at:
Needed to use an array in this.map because I can't be sure that the 'Strategy' object will be called 'Strategy' (see google OAuth2)