From d099d4bda9ecaa823a0874281734d3e0142ff78c Mon Sep 17 00:00:00 2001 From: Dhravya Date: Sun, 14 Apr 2024 13:59:32 -0700 Subject: [PATCH] added limit --- apps/web/src/app/api/store/route.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/web/src/app/api/store/route.ts b/apps/web/src/app/api/store/route.ts index 7fa92b16..f9c1ea40 100644 --- a/apps/web/src/app/api/store/route.ts +++ b/apps/web/src/app/api/store/route.ts @@ -82,9 +82,19 @@ export async function POST(req: NextRequest) { count: sql`count(*)`.mapWith(Number), }) .from(storedContent) - .where(eq(storedContent.user, session.user.id)); + .where( + and( + eq(storedContent.user, session.user.id), + eq(storedContent.type, "page"), + ), + ); - console.log("count", count[0].count); + if (count[0].count > 100) { + return NextResponse.json( + { message: "Error", error: "Limit exceeded" }, + { status: 499 }, + ); + } const { id } = ( await db