1
Fork 0
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:
diced 2025-01-26 14:28:30 -08:00
parent 1be72ba9d9
commit 5cf6a8b53d
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -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,