mirror of
https://github.com/diced/zipline.git
synced 2025-04-11 23:31:17 -05:00
fix: tag checks
This commit is contained in:
parent
1be72ba9d9
commit
5cf6a8b53d
1 changed files with 12 additions and 0 deletions
|
@ -30,6 +30,18 @@ export default fastifyPlugin(
|
|||
server.post<{ Body: Body }>(PATH, { preHandler: [userMiddleware] }, async (req, res) => {
|
||||
const { name, color } = req.body;
|
||||
|
||||
if (!name) return res.badRequest('Name is required');
|
||||
if (!color) return res.badRequest('Color is required');
|
||||
|
||||
const existingTag = await prisma.tag.findFirst({
|
||||
where: {
|
||||
name,
|
||||
userId: req.user.id,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingTag) return res.badRequest('Cannot create tag with the same name');
|
||||
|
||||
const tag = await prisma.tag.create({
|
||||
data: {
|
||||
name,
|
||||
|
|
Loading…
Add table
Reference in a new issue