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