-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.js
More file actions
51 lines (42 loc) · 2 KB
/
router.js
File metadata and controls
51 lines (42 loc) · 2 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
var passport = require('./routes/auth'),
authed = passport.authed,
notAuthed = passport.notAuthed,
user = require('./routes/user'),
endpoint = require('./routes/endpoint'),
dashboard = require('./routes/dashboard.js'),
api = require('./routes/api');
module.exports = function (app) {
app.get('/auth/github', passport.authenticate('github', { scope: ['user:email'] }));
app.get('/auth/github/callback', passport.authenticate('github', { successReturnToOrRedirect: '/profile', failureRedirect: '/login' }));
app.post('/auth/local', passport.authenticate('local', { successReturnToOrRedirect: '/profile', failureRedirect: '/login' }));
app.get('/signup', notAuthed('/dashboard'), user.signup);
app.get('/login', notAuthed('/dashboard'), user.login);
app.post('/user', notAuthed('/dashboard'), user.create);
// Password Forgotten
app.get('/forgot', notAuthed('/dashboard'), user.forgot);
app.post('/forgot', notAuthed('/dashboard'), user.doForgot);
// Secure routes
app.get('/profile', authed, user.profile);
app.get('/logout', authed, function* (){
this.req.logout();
this.response.redirect('/');
});
// Dashboard
app.get('/dashboard', authed, dashboard.get);
app.get('/dashboard/analytics', authed, dashboard.getAnalytics);
app.get('/dashboard/settings', authed, dashboard.getSettings);
app.get('/dashboard/index', authed, dashboard.getIndexOps);
app.get('/dashboard/documentation', authed, dashboard.getDocumentation);
// endpoint
app.post('/endpoint', authed, endpoint.create);
app.get('/upgrade', authed, endpoint.pricing);
app.post('/upgrade', authed, endpoint.upgrade);
app.get('/upgrade/:offerId', authed, endpoint.payment);
// api calls
// app.get('/api', api.doGet);
// app.post('/api', api.doPost);
// app.get('/tapi', require('./lib/thriftApi'));
// loggedout
app.get('/', require('./routes/loggedOut'));
app.get('/pricing', notAuthed('/upgrade'), endpoint.pricing);
};