Separated routes into 3 categories with comments explaining which is which instead of having one giant block of routes.

This commit is contained in:
Sahat Yalkabov
2014-02-01 03:30:14 -05:00
parent b9d8444731
commit e820b9f02a

14
app.js
View File

@ -11,6 +11,10 @@ var mongoose = require('mongoose');
var passport = require('passport');
var expressValidator = require('express-validator');
/**
* Create Express server.
*/
var app = express();
/**
@ -112,6 +116,11 @@ app.get('/api/aviary', apiController.getAviary);
app.get('/api/paypal', apiController.getPayPal);
app.get('/api/paypal/success', apiController.getPayPalSuccess);
app.get('/api/paypal/cancel', apiController.getPayPalCancel);
/**
* OAuth routes for sign-in.
*/
app.get('/auth/facebook', passport.authenticate('facebook', { scope: 'email' }));
app.get('/auth/facebook/callback', passport.authenticate('facebook', { successRedirect: '/', failureRedirect: '/login' }));
app.get('/auth/github', passport.authenticate('github'));
@ -120,6 +129,11 @@ app.get('/auth/google', passport.authenticate('google', { scope: 'profile email'
app.get('/auth/google/callback', passport.authenticate('google', { successRedirect: '/', failureRedirect: '/login' }));
app.get('/auth/twitter', passport.authenticate('twitter'));
app.get('/auth/twitter/callback', passport.authenticate('twitter', { successRedirect: '/', failureRedirect: '/login' }));
/**
* OAuth routes for API examples that require authorization.
*/
app.get('/auth/foursquare', passport.authorize('foursquare'));
app.get('/auth/foursquare/callback', passport.authorize('foursquare', { failureRedirect: '/api' }), function(req, res) {
res.redirect('/api/foursquare');