mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-22 06:41:46 +00:00
chore: apply prettier on the entire project
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import express, { Request, Response } from 'express';
|
||||
import { authenticate, adminOnly } from '../middleware/auth';
|
||||
import { AuthRequest } from '../types';
|
||||
import * as categoryService from '../services/categoryService';
|
||||
import { AuthRequest } from '../types';
|
||||
|
||||
import express, { Request, Response } from 'express';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -19,15 +20,13 @@ router.post('/', authenticate, adminOnly, (req: Request, res: Response) => {
|
||||
|
||||
router.put('/:id', authenticate, adminOnly, (req: Request, res: Response) => {
|
||||
const { name, color, icon } = req.body;
|
||||
if (!categoryService.getCategoryById(req.params.id))
|
||||
return res.status(404).json({ error: 'Category not found' });
|
||||
if (!categoryService.getCategoryById(req.params.id)) return res.status(404).json({ error: 'Category not found' });
|
||||
const category = categoryService.updateCategory(req.params.id, name, color, icon);
|
||||
res.json({ category });
|
||||
});
|
||||
|
||||
router.delete('/:id', authenticate, adminOnly, (req: Request, res: Response) => {
|
||||
if (!categoryService.getCategoryById(req.params.id))
|
||||
return res.status(404).json({ error: 'Category not found' });
|
||||
if (!categoryService.getCategoryById(req.params.id)) return res.status(404).json({ error: 'Category not found' });
|
||||
categoryService.deleteCategory(req.params.id);
|
||||
res.json({ success: true });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user