import passport from 'passport'; import { facebookStrategy, facebookRouter } from './providers/facebook'; import { twitterStrategy, twitterRouter } from './providers/twitter'; import { googleStrategy, googleRouter } from './providers/google'; import { Router } from 'express' import UserModel, { User } from '../models/user' export function initPassport(): void { passport.serializeUser((user: User, done) => { done(null, user.id); }); passport.deserializeUser((id, done) => { UserModel.findById(id, (err, user) => { done(err, user); }); }); passport.use('facebook', facebookStrategy()); passport.use('twitter', twitterStrategy()); passport.use('google', googleStrategy()); } export const authRouter = Router(); authRouter.use(facebookRouter); authRouter.use(twitterRouter); authRouter.use(googleRouter);