Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

update domains/count

Pedro Ladeira94eb52c4fad4
diff --git a/apps/web/app/api/domains/count/route.ts b/apps/web/app/api/domains/count/route.ts
index c40c4eba25..29097d474d 100644
--- a/apps/web/app/api/domains/count/route.ts
+++ b/apps/web/app/api/domains/count/route.ts
@@ -1,26 +1,14 @@
-import { withWorkspace } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
-import { getDomainsCountQuerySchema } from "@/lib/zod/schemas/domains";
import { NextResponse } from "next/server";
-// GET /api/domains/count – get the number of domains for a workspace
-export const GET = withWorkspace(
- async ({ headers, searchParams, workspace }) => {
- const { archived, search } = getDomainsCountQuerySchema.parse(searchParams);
+// GET /api/domains/count – get the number of domains for a workspace
+export const GET = async (req: Request) => {
+ const workspaceId = new URL(req.url).searchParams.get("workspaceId");
+ const domains = await prisma.domain.findMany({
+ where: {
+ projectId: workspaceId ?? undefined,
+ },
+ });
- const count = await prisma.domain.count({
- where: {
- projectId: searchParams.workspaceId || workspace.id,
- archived,
- ...(search && { slug: { contains: search } }),
- },
- });
-
- return NextResponse.json(count, {
- headers,
- });
- },
- {
- requiredPermissions: ["domains.read"],
- },
-);
+ return NextResponse.json(domains);
+};