The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update domains.ts
Steven Tey5aa903231df0
diff --git a/apps/web/lib/api/domains.ts b/apps/web/lib/api/domains.tsindex c22d8892bb..c0f05abde2 100644--- a/apps/web/lib/api/domains.ts+++ b/apps/web/lib/api/domains.ts@@ -239,23 +239,36 @@ export async function deleteDomainAndLinks(skipPrismaDelete = false,} = {},) {- const domainData = await prisma.domain.findUnique({- where: {- slug: domain,- },- select: {- id: true,- target: true,- projectId: true,- },- });+ const [domainData, allLinks] = await Promise.all([+ prisma.domain.findUnique({+ where: {+ slug: domain,+ },+ select: {+ id: true,+ target: true,+ projectId: true,+ },+ }),+ prisma.link.findMany({+ where: {+ domain,+ },+ select: {+ id: true,+ key: true,+ url: true,+ projectId: true,+ },+ }),+ ]);if (!domainData) {return null;}return await Promise.allSettled([// delete all links from redisredis.del(domain),- // record delete in tinybird+ // record deletes in tinybird for domain & linksrecordLink({link: {id: domainData.id,@@ -266,6 +279,18 @@ export async function deleteDomainAndLinks(},deleted: true,}),+ ...allLinks.map(({ id, key, url, projectId }) =>+ recordLink({+ link: {+ id,+ domain,+ key,+ url,+ projectId,+ },+ deleted: true,+ }),+ ),// remove all images from cloudinarycloudinary.v2.api.delete_resources_by_prefix(domain),// remove the domain from Vercel