21 lines
530 B
JavaScript
21 lines
530 B
JavaScript
import express from 'express'
|
|
const router = express.Router()
|
|
import { list, show, create, update, remove } from '../controllers/games.js'
|
|
import { protect, authorize } from '../middleware/auth.js'
|
|
import advancedResults from '../middleware/advancedResults.js'
|
|
import Game from '../models/Game.js'
|
|
|
|
router.use(protect)
|
|
router.use(authorize('user', 'admin'))
|
|
|
|
router.route('/')
|
|
.get(advancedResults(Game), list)
|
|
.post(create)
|
|
|
|
router.route('/:id')
|
|
.get(show)
|
|
.put(update)
|
|
.delete(remove)
|
|
|
|
export default router
|