From 8394fdd43ffc7606d82c5b2cbf523ee983fc9778 Mon Sep 17 00:00:00 2001 From: UltraLionFr Date: Wed, 20 Aug 2025 18:15:23 +0200 Subject: [PATCH] Fix user-pastes --- app/api/user-pastes/route.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/api/user-pastes/route.ts b/app/api/user-pastes/route.ts index 63e1b4d..e2accb1 100644 --- a/app/api/user-pastes/route.ts +++ b/app/api/user-pastes/route.ts @@ -1,5 +1,6 @@ import { authOptions } from '@/lib/auth'; import { prisma } from '@/lib/prisma'; +import { Prisma } from '@prisma/client'; import { getServerSession } from 'next-auth'; import { NextResponse } from 'next/server'; @@ -17,17 +18,18 @@ export async function GET(req: Request) { const search = searchParams.get('q') || ''; -const filter = { - createdBy: session.user.id, - ...(search - ? { - title: { - contains: search, - mode: 'insensitive', - }, - } - : {}), -} as const; + // ✅ Typage explicite avec Prisma + const filter: Prisma.PasteWhereInput = { + createdBy: session.user.id, + ...(search + ? { + title: { + contains: search, + mode: 'insensitive', // correspond au type Prisma.QueryMode + }, + } + : {}), + }; const [pastes, total] = await Promise.all([ prisma.paste.findMany({ @@ -42,4 +44,4 @@ const filter = { ]); return NextResponse.json({ pastes, total }); -} +} \ No newline at end of file