Fixed catgory post

This commit is contained in:
Florian Sylvain
2023-02-01 09:43:00 +01:00
parent 392610c6fc
commit 0cf7ac2670
2 changed files with 2 additions and 2 deletions
-1
View File
@@ -2,7 +2,6 @@ import { initServer } from '../app.js'
import request from 'supertest' import request from 'supertest'
import { PrismaClient } from '@prisma/client' import { PrismaClient } from '@prisma/client'
import bcrypt from 'bcrypt' import bcrypt from 'bcrypt'
import { equals } from '@jest/expect-utils'
const prisma = new PrismaClient() const prisma = new PrismaClient()
const app = initServer() const app = initServer()
+2 -1
View File
@@ -10,6 +10,7 @@ const categoryData = z.object({
name: z.string().max(50) name: z.string().max(50)
}).required() }).required()
// TODO Mettre le where sur le user id plutot que sur un nom de category
const categoryGet: RequestHandler = async (req, res) => { const categoryGet: RequestHandler = async (req, res) => {
let category: Category | null = null let category: Category | null = null
@@ -33,7 +34,7 @@ const categoryPost: RequestHandler = async (req, res) => {
try { try {
const newCategory = categoryData.parse(req.body) const newCategory = categoryData.parse(req.body)
prisma.category.create({ await prisma.category.create({
data: { data: {
name: newCategory.name, name: newCategory.name,
user_id: userId user_id: userId