-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.js
33 lines (28 loc) · 1.47 KB
/
router.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
const passport = require('passport');
const passportService = require('./services/passport');
const authentication = require('./controllers/authentication');
const trips = require('./controllers/trips')
const activities = require('./controllers/activities');
const requireAuth = passport.authenticate('jwt', { session: false });
const requireSignin = passport.authenticate('local', { session: false });
module.exports = function(app) {
// Authentication Routes
app.post('/signin', requireSignin, authentication.signin);
app.post('/signup', authentication.signup);
app.post('/forgot', authentication.forgot);
app.post('/reset/:token', authentication.reset);
// Trip Routes
app.get('/user/:username', requireAuth, trips.showAll);
app.post('/user/:username', requireAuth, trips.create);
app.put('/user/:username/trip/:tripId', requireAuth, trips.update);
app.delete('/user/:username/trip/:tripId', requireAuth, trips.delete);
// Activity Routes
app.get('/user/:username/trip/:tripId', requireAuth, activities.showAll);
app.post('/user/:username/trip/:tripId/activity', requireAuth, activities.create);
app.get('/user/:username/trip/:tripId/activity/:activityId', requireAuth, activities.show);
app.put('/user/:username/trip/:tripId/activity/:activityId', requireAuth, activities.update);
app.delete('/user/:username/trip/:tripId/activity/:activityId', requireAuth, activities.delete);
app.get('*', function(req, res) {
res.send('Server is running...');
});
}