Matching UI with improved API

This commit is contained in:
2024-09-24 13:12:44 +02:00
parent bc62174566
commit abe1b496a2
34 changed files with 194 additions and 545 deletions

View File

@@ -7,7 +7,7 @@ export const category = Router()
category.get("/", (req: Request, res: Response, next: NextFunction) => {
Category.findAll()
.then(categories => {
res.status(200).json(categories).send()
res.status(200).json(categories)
})
})
@@ -15,13 +15,13 @@ category.get("/", (req: Request, res: Response, next: NextFunction) => {
category.post("/", (req: Request, res: Response, next: NextFunction) => {
Category.create(req.body)
.then(category => {
res.status(201).json(category).send()
res.status(201).json(category)
})
.catch(error => {
res.status(400).json({
code: 400,
message: error
}).send()
})
})
})
@@ -31,12 +31,12 @@ category.delete("/:id", (req: Request, res: Response, next: NextFunction) => {
where: { id: req.params.id }
})
.then(category => {
res.status(200).json(category).send()
res.status(200).json(category)
})
.catch(error => {
res.status(400).json({
code: 400,
message: error
}).send()
})
})
})