|
|
@ -12,7 +12,7 @@ router.get('/', async (req, res) => {
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/by-slug/:slug', async (req, res) => {
|
|
|
|
router.get('/by-slug/:slug', async (req, res) => {
|
|
|
|
const category = await db.category.findBySlug(req.params.slug)
|
|
|
|
const category = await db.category.findBySlug(req.params.slug)
|
|
|
|
|
|
|
|
|
|
|
|
res.json(category)
|
|
|
|
res.json(category)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
@ -32,6 +32,17 @@ router.post('/', parseJSON, newCategoryValidators, async (req, res) => {
|
|
|
|
res.json(category)
|
|
|
|
res.json(category)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/:uuid', parseJSON, newCategoryValidators, async (req, res) => {
|
|
|
|
|
|
|
|
const category = await db.category.update(
|
|
|
|
|
|
|
|
req.params.uuid,
|
|
|
|
|
|
|
|
req.body.name,
|
|
|
|
|
|
|
|
req.body.urlslug,
|
|
|
|
|
|
|
|
req.body.description
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.json(category)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
router.put('/:category_uuid/items/:item_uuid', async (req, res) => {
|
|
|
|
router.put('/:category_uuid/items/:item_uuid', async (req, res) => {
|
|
|
|
const category = await db.category.addItem(req.params.category_uuid, req.params.item_uuid);
|
|
|
|
const category = await db.category.addItem(req.params.category_uuid, req.params.item_uuid);
|
|
|
|
res.json(category)
|
|
|
|
res.json(category)
|
|
|
|