2021-05-22 17:04:34 +00:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
|
|
|
|
2021-11-11 15:43:00 +00:00
|
|
|
// middleware
|
|
|
|
const { auth, requireAuth } = require('../middleware');
|
|
|
|
|
2021-05-22 17:04:34 +00:00
|
|
|
const {
|
|
|
|
createCategory,
|
2021-11-04 22:39:35 +00:00
|
|
|
getAllCategories,
|
|
|
|
getSingleCategory,
|
2021-05-22 17:04:34 +00:00
|
|
|
updateCategory,
|
2021-06-18 11:42:55 +00:00
|
|
|
deleteCategory,
|
2021-11-04 22:39:35 +00:00
|
|
|
reorderCategories,
|
|
|
|
} = require('../controllers/categories');
|
2021-05-22 17:04:34 +00:00
|
|
|
|
2021-11-11 15:43:00 +00:00
|
|
|
router
|
|
|
|
.route('/')
|
|
|
|
.post(auth, requireAuth, createCategory)
|
|
|
|
.get(auth, getAllCategories);
|
2021-05-22 17:04:34 +00:00
|
|
|
|
|
|
|
router
|
|
|
|
.route('/:id')
|
2021-11-11 15:43:00 +00:00
|
|
|
.get(auth, getSingleCategory)
|
|
|
|
.put(auth, requireAuth, updateCategory)
|
|
|
|
.delete(auth, requireAuth, deleteCategory);
|
2021-05-22 17:04:34 +00:00
|
|
|
|
2021-11-11 15:43:00 +00:00
|
|
|
router.route('/0/reorder').put(auth, requireAuth, reorderCategories);
|
2021-06-18 11:42:55 +00:00
|
|
|
|
2021-11-04 22:39:35 +00:00
|
|
|
module.exports = router;
|