From 0cf7ac26702f1b072a911f5c4c4a67fa8eb94544 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Wed, 1 Feb 2023 09:43:00 +0100 Subject: [PATCH] Fixed catgory post --- src/__tests__/app.test.ts | 1 - src/routers/category.ts | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__tests__/app.test.ts b/src/__tests__/app.test.ts index 15cecb9..a4f8f71 100644 --- a/src/__tests__/app.test.ts +++ b/src/__tests__/app.test.ts @@ -2,7 +2,6 @@ import { initServer } from '../app.js' import request from 'supertest' import { PrismaClient } from '@prisma/client' import bcrypt from 'bcrypt' -import { equals } from '@jest/expect-utils' const prisma = new PrismaClient() const app = initServer() diff --git a/src/routers/category.ts b/src/routers/category.ts index 28fc48b..e7f0303 100644 --- a/src/routers/category.ts +++ b/src/routers/category.ts @@ -10,6 +10,7 @@ const categoryData = z.object({ name: z.string().max(50) }).required() +// TODO Mettre le where sur le user id plutot que sur un nom de category const categoryGet: RequestHandler = async (req, res) => { let category: Category | null = null @@ -33,7 +34,7 @@ const categoryPost: RequestHandler = async (req, res) => { try { const newCategory = categoryData.parse(req.body) - prisma.category.create({ + await prisma.category.create({ data: { name: newCategory.name, user_id: userId