The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
decrement
Steven Tey23a83629521c
diff --git a/apps/web/app/api/links/[linkId]/route.ts b/apps/web/app/api/links/[linkId]/route.tsindex 82dbcecefe..6af9d8949d 100644--- a/apps/web/app/api/links/[linkId]/route.ts+++ b/apps/web/app/api/links/[linkId]/route.ts@@ -89,11 +89,12 @@ export const PUT = withAuth();// DELETE /api/links/[linkId] – delete a link-export const DELETE = withAuth(async ({ headers, link }) => {+export const DELETE = withAuth(async ({ headers, link, project }) => {// link is guaranteed to exist because if not we will return 404const response = await deleteLink({domain: link!.domain,key: link!.key,+ projectId: project.id,});return NextResponse.json(response[0], {headers,diff --git a/apps/web/lib/api/links.ts b/apps/web/lib/api/links.tsindex 7804a83f87..143d2e5c89 100644--- a/apps/web/lib/api/links.ts+++ b/apps/web/lib/api/links.ts@@ -663,9 +663,11 @@ export async function editLink({export async function deleteLink({domain = SHORT_DOMAIN,key,+ projectId,}: {domain?: string;key: string;+ projectId?: string;}) {return await Promise.all([prisma.link.delete({@@ -680,6 +682,17 @@ export async function deleteLink({invalidate: true,}),redis.del(`${domain}:${key}`),+ projectId &&+ prisma.project.update({+ where: {+ id: projectId,+ },+ data: {+ linksUsage: {+ decrement: 1,+ },+ },+ }),]);}