Skip to content

Commit

Permalink
Merge branch 'main' into fix/domain-transfer-validation-error
Browse files Browse the repository at this point in the history
  • Loading branch information
devkiran authored Dec 20, 2024
2 parents 2b7340e + 928a050 commit e798b0b
Show file tree
Hide file tree
Showing 735 changed files with 10,852 additions and 7,605 deletions.
8 changes: 1 addition & 7 deletions apps/web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,4 @@ SLACK_CLIENT_SECRET=
SLACK_SIGNING_SECRET=

# Dynadot API key for domain registration
DYNADOT_API_KEY=

# Dots for Partner Payouts
DOTS_API_URL=
DOTS_CLIENT_ID=
DOTS_API_KEY=
DOTS_DEFAULT_APP_ID=
DYNADOT_API_KEY=
8 changes: 2 additions & 6 deletions apps/web/app/[domain]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { constructMetadata } from "@dub/utils";
import PlaceholderContent from "./placeholder";

export const revalidate = 0;
export const runtime = "edge";

export async function generateMetadata({
params,
}: {
params: { domain: string };
}) {
export function generateMetadata({ params }: { params: { domain: string } }) {
const title = `${params.domain.toUpperCase()} - A ${
process.env.NEXT_PUBLIC_APP_NAME
} Custom Domain`;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/[domain]/stats/[key]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prismaEdge } from "@/lib/prisma/edge";
import { prismaEdge } from "@dub/prisma/edge";
import { APP_DOMAIN } from "@dub/utils";
import { notFound, redirect } from "next/navigation";

Expand Down
1 change: 0 additions & 1 deletion apps/web/app/admin.dub.co/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { constructMetadata } from "@dub/utils";
import Link from "next/link";
import { ReactNode } from "react";

export const dynamic = "force-static";
export const metadata = constructMetadata({ noIndex: true });

const tabs = [
Expand Down
7 changes: 6 additions & 1 deletion apps/web/app/admin.dub.co/(dashboard)/links/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import AdminLinksClient from "app/app.dub.co/(dashboard)/[slug]/page-client";
import { Suspense } from "react";

export default function AdminLinks() {
return <AdminLinksClient />;
return (
<Suspense>
<AdminLinksClient />
</Suspense>
);
}
5 changes: 1 addition & 4 deletions apps/web/app/admin.dub.co/(dashboard)/revenue/client.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
"use client";

import Areas from "@/ui/charts/areas";
import TimeSeriesChart from "@/ui/charts/time-series-chart";
import XAxis from "@/ui/charts/x-axis";
import YAxis from "@/ui/charts/y-axis";
import { Areas, TimeSeriesChart, XAxis, YAxis } from "@dub/ui/charts";
import { currencyFormatter } from "@dub/utils";
import { Fragment } from "react";

Expand Down
3 changes: 1 addition & 2 deletions apps/web/app/api/admin/ban/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { deleteWorkspaceAdmin } from "@/lib/api/workspaces";
import { withAdmin } from "@/lib/auth";
import { updateConfig } from "@/lib/edge-config";
import { prisma } from "@/lib/prisma";
import { unsubscribe } from "@/lib/resend";
import { isStored, storage } from "@/lib/storage";
import { prisma } from "@dub/prisma";
import { R2_URL } from "@dub/utils";
import { waitUntil } from "@vercel/functions";
import { NextResponse } from "next/server";
Expand Down Expand Up @@ -31,7 +31,6 @@ export const POST = withAdmin(async ({ req }) => {
slug: true,
logo: true,
stripeId: true,
referralLinkId: true,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/admin/impersonate/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hashToken, withAdmin } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { APP_DOMAIN, DUB_DOMAINS_ARRAY, PARTNERS_DOMAIN } from "@dub/utils";
import { randomBytes } from "crypto";
import { NextResponse } from "next/server";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/admin/links/[linkId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { withAdmin } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { NextResponse } from "next/server";

// GET /api/admin/links/[linkId] – get a link as an admin
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/admin/links/ban/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { withAdmin } from "@/lib/auth";
import { updateConfig } from "@/lib/edge-config";
import { prisma } from "@/lib/prisma";
import { formatRedisLink, redis } from "@/lib/upstash";
import { domainKeySchema } from "@/lib/zod/schemas/links";
import { prisma } from "@dub/prisma";
import {
LEGAL_USER_ID,
LEGAL_WORKSPACE_ID,
Expand Down
7 changes: 5 additions & 2 deletions apps/web/app/api/admin/links/count/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { withAdmin } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { DUB_DOMAINS_ARRAY } from "@dub/utils";
import { prisma } from "@dub/prisma";
import { DUB_DOMAINS_ARRAY, LEGAL_USER_ID } from "@dub/utils";
import { NextResponse } from "next/server";

// GET /api/admin/links/count
Expand All @@ -17,6 +17,9 @@ export const GET = withAdmin(async ({ searchParams }) => {
const tagIds = tagId ? tagId.split(",") : [];

const linksWhere = {
userId: {
not: LEGAL_USER_ID,
},
// when filtering by domain, only filter by domain if the filter group is not "Domains"
...(domain && groupBy !== "domain"
? {
Expand Down
7 changes: 5 additions & 2 deletions apps/web/app/api/admin/links/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { withAdmin } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { DUB_DOMAINS_ARRAY } from "@dub/utils";
import { prisma } from "@dub/prisma";
import { DUB_DOMAINS_ARRAY, LEGAL_USER_ID } from "@dub/utils";
import { NextResponse } from "next/server";

// GET /api/admin/links
Expand All @@ -19,6 +19,9 @@ export const GET = withAdmin(async ({ searchParams }) => {

const response = await prisma.link.findMany({
where: {
userId: {
not: LEGAL_USER_ID,
},
...(domain
? { domain }
: {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/ai/completion/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { withWorkspaceEdge } from "@/lib/auth/workspace-edge";
import { prismaEdge } from "@/lib/prisma/edge";
import z from "@/lib/zod";
import { anthropic } from "@ai-sdk/anthropic";
import { prismaEdge } from "@dub/prisma/edge";
import { waitUntil } from "@vercel/functions";
import { streamText } from "ai";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/analytics/dashboard/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
exceededLimitError,
handleAndReturnErrorResponse,
} from "@/lib/api/errors";
import { prisma } from "@/lib/prisma";
import { PlanProps } from "@/lib/types";
import { ratelimit } from "@/lib/upstash";
import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";
import { prisma } from "@dub/prisma";
import { DUB_DEMO_LINKS, DUB_WORKSPACE_ID, getSearchParams } from "@dub/utils";
import { ipAddress } from "@vercel/functions";
import { NextResponse } from "next/server";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/analytics/export/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getLinkOrThrow } from "@/lib/api/links/get-link-or-throw";
import { throwIfClicksUsageExceeded } from "@/lib/api/links/usage-checks";
import { withWorkspace } from "@/lib/auth";
import { analyticsQuerySchema } from "@/lib/zod/schemas/analytics";
import { Link } from "@prisma/client";
import { Link } from "@dub/prisma/client";
import JSZip from "jszip";

// GET /api/analytics/export – get export data for analytics
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/analytics/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
analyticsPathParamsSchema,
analyticsQuerySchema,
} from "@/lib/zod/schemas/analytics";
import { Link } from "@prisma/client";
import { Link } from "@dub/prisma/client";
import { NextResponse } from "next/server";

// GET /api/analytics – get analytics
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/auth/reset-password/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";
import { parseRequestBody, ratelimitOrThrow } from "@/lib/api/utils";
import { hashPassword } from "@/lib/auth/password";
import { prisma } from "@/lib/prisma";
import { resetPasswordSchema } from "@/lib/zod/schemas/auth";
import { prisma } from "@dub/prisma";
import { waitUntil } from "@vercel/functions";
import { sendEmail } from "emails";
import PasswordUpdated from "emails/password-updated";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/auth/saml/verify/route.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import jackson from "@/lib/jackson";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { NextResponse } from "next/server";

export async function POST(req: Request) {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/callback/bitly/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/upstash";
import { prisma } from "@dub/prisma";
import { APP_DOMAIN, APP_DOMAIN_WITH_NGROK } from "@dub/utils";
import { NextResponse } from "next/server";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/callback/plain/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { plain } from "@/lib/plain";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { capitalize, formatDate } from "@dub/utils";
import { NextRequest, NextResponse } from "next/server";
import {
Expand Down
8 changes: 5 additions & 3 deletions apps/web/app/api/cron/cleanup/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { deleteDomainAndLinks } from "@/lib/api/domains";
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { bulkDeleteLinks } from "@/lib/api/links/bulk-delete-links";
import { verifyVercelSignature } from "@/lib/cron/verify-vercel";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { log } from "@dub/utils";
import { NextResponse } from "next/server";

Expand All @@ -11,8 +11,10 @@ export const dynamic = "force-dynamic";
const E2E_USER_ID = "clxz1q7c7000hbqx5ckv4r82h";
const E2E_WORKSPACE_ID = "clrei1gld0002vs9mzn93p8ik";

// Cron to remove links and domains created during the E2E test.
// Run every 6 hours (0 */6 * * *)
/***
This route is used to remove links and domains created during the E2E test.
Runs every 6 hours (0 * / 6 * * *)
*/
export async function GET(req: Request) {
try {
await verifyVercelSignature(req);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/domains/transfer/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { qstash } from "@/lib/cron";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { prisma } from "@/lib/prisma";
import { recordLink } from "@/lib/tinybird";
import z from "@/lib/zod";
import { prisma } from "@dub/prisma";
import { APP_DOMAIN_WITH_NGROK, log } from "@dub/utils";
import { NextResponse } from "next/server";
import { sendDomainTransferredEmail, updateLinksInRedis } from "./utils";
Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/api/cron/domains/transfer/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { prisma } from "@/lib/prisma";
import { formatRedisLink, redis } from "@/lib/upstash";
import { Link } from "@prisma/client";
import { prisma } from "@dub/prisma";
import { Link } from "@dub/prisma/client";
import { sendEmail } from "emails";
import DomainTransferred from "emails/domain-transferred";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/domains/verify/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@/lib/api/domains";
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { verifyVercelSignature } from "@/lib/cron/verify-vercel";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { log } from "@dub/utils";
import { NextResponse } from "next/server";
import { handleDomainUpdates } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/domains/verify/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { deleteDomainAndLinks } from "@/lib/api/domains";
import { limiter } from "@/lib/cron/limiter";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { log } from "@dub/utils";
import { sendEmail } from "emails";
import DomainDeleted from "emails/domain-deleted";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/bitly/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";
import { createId } from "@/lib/api/utils";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/upstash";
import { randomBadgeColor } from "@/ui/links/tag-badge";
import { prisma } from "@dub/prisma";
import { log } from "@dub/utils";
import { NextResponse } from "next/server";
import { importLinksFromBitly } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/bitly/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { bulkCreateLinks } from "@/lib/api/links";
import { qstash } from "@/lib/cron";
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/upstash";
import { prisma } from "@dub/prisma";
import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
import { sendEmail } from "emails";
import LinksImported from "emails/links-imported";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/csv/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { bulkCreateLinks, createLink, processLink } from "@/lib/api/links";
import { createId } from "@/lib/api/utils";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { prisma } from "@/lib/prisma";
import { storage } from "@/lib/storage";
import { ProcessedLinkProps, WorkspaceProps } from "@/lib/types";
import { redis } from "@/lib/upstash";
import { linkMappingSchema } from "@/lib/zod/schemas/import-csv";
import { createLinkBodySchema } from "@/lib/zod/schemas/links";
import { randomBadgeColor } from "@/ui/links/tag-badge";
import { prisma } from "@dub/prisma";
import {
DEFAULT_LINK_PROPS,
DUB_DOMAINS_ARRAY,
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/csv/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";
import { sendEmail } from "emails";
import { LinksImportErrors } from "emails/links-import-errors";
import LinksImported from "emails/links-imported";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/rebrandly/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/upstash";
import { prisma } from "@dub/prisma";
import { log } from "@dub/utils";
import { NextResponse } from "next/server";
import { importLinksFromRebrandly, importTagsFromRebrandly } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/rebrandly/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { bulkCreateLinks } from "@/lib/api/links";
import { createId } from "@/lib/api/utils";
import { qstash } from "@/lib/cron";
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/upstash";
import { randomBadgeColor } from "@/ui/links/tag-badge";
import { prisma } from "@dub/prisma";
import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
import { sendEmail } from "emails";
import LinksImported from "emails/links-imported";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/short/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DubApiError, handleAndReturnErrorResponse } from "@/lib/api/errors";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/upstash";
import { prisma } from "@dub/prisma";
import { log } from "@dub/utils";
import { NextResponse } from "next/server";
import { importLinksFromShort } from "./utils";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/cron/import/short/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { bulkCreateLinks } from "@/lib/api/links";
import { createId } from "@/lib/api/utils";
import { qstash } from "@/lib/cron";
import { prisma } from "@/lib/prisma";
import { redis } from "@/lib/upstash";
import { randomBadgeColor } from "@/ui/links/tag-badge";
import { prisma } from "@dub/prisma";
import { APP_DOMAIN_WITH_NGROK } from "@dub/utils";
import { sendEmail } from "emails";
import LinksImported from "emails/links-imported";
Expand Down
6 changes: 5 additions & 1 deletion apps/web/app/api/cron/links/delete/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { handleAndReturnErrorResponse } from "@/lib/api/errors";
import { deleteLink } from "@/lib/api/links";
import { verifyQstashSignature } from "@/lib/cron/verify-qstash";
import { prisma } from "@/lib/prisma";
import { prisma } from "@dub/prisma";

export const dynamic = "force-dynamic";

/*
This route is used to delete demo links that are not claimed
It is called by QStash 30 minutes after a demo link is created
*/
export async function POST(req: Request) {
try {
const body = await req.json();
Expand Down
18 changes: 0 additions & 18 deletions apps/web/app/api/cron/payouts/route.ts

This file was deleted.

Loading

0 comments on commit e798b0b

Please sign in to comment.