games-express-api/routes/users.js

29 lines
612 B
JavaScript

import express from 'express'
const router = express.Router({ mergeParams: true })
import User from '../models/User.js'
import {
getUsers,
getUser,
createUser,
updateUser,
deleteUser,
} from '../controllers/users.js'
import advancedResults from '../middleware/advancedResults.js'
import { protect, authorize } from '../middleware/auth.js'
router.use(protect)
router.use(authorize('admin'))
router
.route('/')
.get(advancedResults(User), getUsers)
.post(createUser)
router
.route('/:id')
.get(getUser)
.put(updateUser)
.delete(deleteUser)
export default router