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.

rename

Steven Tey4f140a67bb19
diff --git a/apps/web/app/api/embed/invite/route.ts b/apps/web/app/api/embed/invite/route.ts
deleted file mode 100644
index ea9aead972..0000000000
--- a/apps/web/app/api/embed/invite/route.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { invitePartner } from "@/lib/api/partners/invite-partner";
-import { parseRequestBody } from "@/lib/api/utils";
-import { requestPartnerInviteSchema } from "@/lib/dots/schemas";
-import { withEmbedToken } from "@/lib/embed/auth";
-import { prisma } from "@/lib/prisma";
-import { NextResponse } from "next/server";
-
-// GET /api/referrals/invite - check if a partner is already invited to a program
-export const GET = withEmbedToken(async ({ link, program }) => {
- const [programEnrollment, programInvite] = await Promise.all([
- prisma.programEnrollment.findFirst({
- where: {
- programId: program.id,
- linkId: link.id,
- },
- }),
-
- prisma.programInvite.findFirst({
- where: {
- programId: program.id,
- linkId: link.id,
- },
- }),
- ]);
-
- return NextResponse.json({
- programEnrollment,
- programInvite,
- });
-});
-
-// POST /api/referrals/invite - invite a partner to dub partners
-export const POST = withEmbedToken(
- async ({ req, link, program, workspace }) => {
- const { email } = requestPartnerInviteSchema.parse(
- await parseRequestBody(req),
- );
-
- const programInvited = await invitePartner({
- email,
- program,
- link,
- workspace,
- });
-
- return NextResponse.json(programInvited);
- },
-);
diff --git a/apps/web/app/api/embed/sales/count/route.ts b/apps/web/app/api/embed/sales/count/route.ts
deleted file mode 100644
index 2373ea5c6b..0000000000
--- a/apps/web/app/api/embed/sales/count/route.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { getStartEndDates } from "@/lib/analytics/utils/get-start-end-dates";
-import { withEmbedToken } from "@/lib/embed/auth";
-import { prisma } from "@/lib/prisma";
-import { getPartnerSalesCountQuerySchema } from "@/lib/zod/schemas/partners";
-import { NextResponse } from "next/server";
-
-// GET /api/referrals/sales/count – get sales count for a link
-export const GET = withEmbedToken(async ({ searchParams, link }) => {
- const parsed = getPartnerSalesCountQuerySchema.parse(searchParams);
- const { startDate, endDate } = getStartEndDates(parsed);
-
- const salesCount = await prisma.sale.count({
- where: {
- linkId: link.id,
- createdAt: {
- gte: startDate.toISOString(),
- lte: endDate.toISOString(),
- },
- },
- });
-
- return NextResponse.json({ count: salesCount });
-});
diff --git a/apps/web/app/api/embed/sales/route.ts b/apps/web/app/api/embed/sales/route.ts
index 63c7faad0b..ff57e941ef 100644
--- a/apps/web/app/api/embed/sales/route.ts
+++ b/apps/web/app/api/embed/sales/route.ts
@@ -4,7 +4,7 @@ import z from "@/lib/zod";
import { PartnerSaleResponseSchema } from "@/lib/zod/schemas/partners";
import { NextResponse } from "next/server";
-// GET /api/referrals/sales – get sales for a link
+// GET /api/embed/sales – get sales for a link from an embed token
export const GET = withEmbedToken(async ({ link }) => {
const sales = await prisma.sale.findMany({
where: {
diff --git a/apps/web/app/api/embed/token/route.ts b/apps/web/app/api/embed/token/route.ts
index c5bf5a2cff..cabd97f5f6 100644
--- a/apps/web/app/api/embed/token/route.ts
+++ b/apps/web/app/api/embed/token/route.ts
@@ -1,7 +1,7 @@
import { withEmbedToken } from "@/lib/embed/auth";
import { NextResponse } from "next/server";
-// GET /api/referrals/token - get the embed token for the given link
+// GET /api/embed/token - get the embed token for the given link
export const GET = withEmbedToken(async ({ linkToken }) => {
return NextResponse.json(linkToken);
});