Skip to content

Commit

Permalink
Added events router
Browse files Browse the repository at this point in the history
  • Loading branch information
chaltenio committed Apr 10, 2022
1 parent a31b94c commit 41bd72b
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions routes/events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const express = require('express');

const {
getEvents,
getEvent,
createEvent,
updateEvent,
deleteEvent,
getEventsInRadius,
eventPhotoUpload
} = require('../controllers/Events');

const Event = require('../models/Event');

// Include other resource routers
const courseRouter = require('./talks');
const reviewRouter = require('./reviews');

const router = express.Router();

const advancedResults = require('../middleware/advancedResults');
const { protect, authorize } = require('../middleware/auth');

// Re-route into other resource routers
router.use('/:eventId/talks', courseRouter);
router.use('/:eventId/reviews', reviewRouter);

router.route('/radius/:zipcode/:distance').get(getEventsInRadius);

router.route('/:id/photo').put(protect, authorize('publisher', 'admin'), eventPhotoUpload);

router
.route('/')
.get(advancedResults(Event, 'talks'), getEvents)
.post(protect, authorize('publisher', 'admin'), createEvent);

router
.route('/:id')
.get(getEvent)
.put(protect, authorize('publisher', 'admin'), updateEvent)
.delete(protect, authorize('publisher', 'admin'), deleteEvent);

module.exports = router;

0 comments on commit 41bd72b

Please sign in to comment.