-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathroutes.js
46 lines (35 loc) · 1.26 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
40
41
42
43
44
45
46
var express = require('express');
var passport = require('passport');
var middleware = require('./routehandlers/middleware');
var index = require('./routehandlers/index');
var auth = require('./routehandlers/auth');
var me = require('./routehandlers/me');
var appointments = require('./routehandlers/appointments');
var router = express.Router();
// Index
router.get('/', index.index);
// Me
router.get('/me', middleware.ensureAuthenticated, me)
// Authentication provider routes
router.get('/auth/google',
passport.authenticate('google', { scope: ['email', 'profile'] })
);
router.get('/auth/google/callback',
passport.authenticate('google', { scope: ['email', 'profile'] }),
auth.externalcallback
);
router.post('/auth/google', auth.googletoken);
router.get('/auth/loggedin', auth.loggedin);
// Appointments
router.route('/appointments')
.all(middleware.ensureAuthenticated)
.get(appointments.getByUser)
.post(middleware.sanitizeRequestBody, appointments.create);
router.route('/appointments/:id')
.all(middleware.ensureAuthenticated)
.get(appointments.getById)
.put(middleware.sanitizeRequestBody, appointments.update)
.patch(middleware.sanitizeRequestBody, appointments.update)
.delete(appointments.delete);
// --
module.exports.router = router;