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 route.ts

Kiran Ka3c96d900bf3
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
index 8d734f7383..edfd24be19 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/route.ts
@@ -8,23 +8,34 @@ import {
BountySchemaExtended,
updateBountySchema,
} from "@/lib/zod/schemas/bounties";
+import { booleanQuerySchema } from "@/lib/zod/schemas/misc";
import { prisma } from "@dub/prisma";
import { Prisma } from "@prisma/client";
import { waitUntil } from "@vercel/functions";
import { NextResponse } from "next/server";
+import { z } from "zod";
+
+const schema = z.object({
+ includeExpandedFields: booleanQuerySchema.optional().default("false"),
+});
// GET /api/bounties/[bountyId] - get a bounty
-export const GET = withWorkspace(async ({ workspace, params }) => {
- const { bountyId } = params;
- const programId = getDefaultProgramIdOrThrow(workspace);
+export const GET = withWorkspace(
+ async ({ workspace, params, searchParams }) => {
+ const { bountyId } = params;
- const bounty = await getBountyOrThrow({
- bountyId,
- programId,
- });
+ const programId = getDefaultProgramIdOrThrow(workspace);
+ const { includeExpandedFields } = schema.parse(searchParams);
- return NextResponse.json(BountySchemaExtended.parse(bounty));
-});
+ const bounty = await getBountyOrThrow({
+ bountyId,
+ programId,
+ includeExpandedFields,
+ });
+
+ return NextResponse.json(BountySchemaExtended.parse(bounty));
+ },
+);
// PATCH /api/bounties/[bountyId] - update a bounty
export const PATCH = withWorkspace(async ({ workspace, params, req }) => {