Skip to content

Commit

Permalink
added limit
Browse files Browse the repository at this point in the history
Dhravya committed Apr 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0a29564 commit d099d4b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions apps/web/src/app/api/store/route.ts
Original file line number Diff line number Diff line change
@@ -82,9 +82,19 @@ export async function POST(req: NextRequest) {
count: sql<number>`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

0 comments on commit d099d4b

Please sign in to comment.