Extend database with more tables, rewrite API doc, improve API endpoints

This commit is contained in:
2024-09-23 21:22:45 +02:00
parent 8b4db9ccc8
commit b245e3803a
41 changed files with 1345 additions and 1126 deletions

View File

@@ -9,19 +9,17 @@ category.get("/", (req: Request, res: Response, next: NextFunction) => {
.then(categories => {
res.status(200).json(categories).send()
})
.catch(error => {
res.status(400)
})
})
// Add new category
category.post("/", (req: Request, res: Response, next: NextFunction) => {
Category.create(req.body)
.then(category => {
res.status(201).send()
res.status(201).json(category).send()
})
.catch(error => {
res.status(400).json({
code: 400,
message: error
}).send()
})
@@ -33,10 +31,11 @@ category.delete("/:id", (req: Request, res: Response, next: NextFunction) => {
where: { id: req.params.id }
})
.then(category => {
res.status(200).send()
res.status(200).json(category).send()
})
.catch(error => {
res.status(400).json({
code: 400,
message: error
}).send()
})