-
Notifications
You must be signed in to change notification settings - Fork 10
/
routes.js
executable file
·39 lines (31 loc) · 2.08 KB
/
routes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var async = require('async')
module.exports = function (app, passport, auth) {
// user routes
var users = require('../app/controllers/users')
app.get('/signin', users.signin)
app.get('/signup', users.signup)
app.get('/signout', users.signout)
app.post('/users', users.create)
app.post('/users/session', passport.authenticate('local', {failureRedirect: '/signin', failureFlash: 'Invalid email or password.'}), users.session)
app.get('/users/me', users.me)
app.get('/users/:userId', users.show)
app.get('/auth/facebook', passport.authenticate('facebook', { scope: [ 'email', 'user_about_me'], failureRedirect: '/signin' }), users.signin)
app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/signin' }), users.authCallback)
app.get('/auth/github', passport.authenticate('github', { failureRedirect: '/signin' }), users.signin)
app.get('/auth/github/callback', passport.authenticate('github', { failureRedirect: '/signin' }), users.authCallback)
app.get('/auth/twitter', passport.authenticate('twitter', { failureRedirect: '/signin' }), users.signin)
app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/signin' }), users.authCallback)
app.get('/auth/google', passport.authenticate('google', { failureRedirect: '/signin', scope: 'https://www.google.com/m8/feeds' }), users.signin)
app.get('/auth/google/callback', passport.authenticate('google', { failureRedirect: '/signin', scope: 'https://www.google.com/m8/feeds' }), users.authCallback)
app.param('userId', users.user)
var articles = require('../app/controllers/articles')
app.get('/articles', articles.all)
app.post('/articles', auth.requiresLogin, articles.create)
app.get('/articles/:articleId', articles.show)
app.put('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.update)
app.del('/articles/:articleId', auth.requiresLogin, auth.article.hasAuthorization, articles.destroy)
app.param('articleId', articles.article)
// home route
var index = require('../app/controllers/index')
app.get('/', index.render)
}