flame/routes/category.js

30 lines
646 B
JavaScript
Raw Normal View History

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