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.

finalize eligibleWorkspaces

Steven Tey251b6bb88340
diff --git a/apps/web/app/(ee)/api/domains/register/route.ts b/apps/web/app/(ee)/api/domains/register/route.ts
index f4d4b10597..8d2e11676b 100644
--- a/apps/web/app/(ee)/api/domains/register/route.ts
+++ b/apps/web/app/(ee)/api/domains/register/route.ts
@@ -1,14 +1,29 @@
import { claimDotLinkDomain } from "@/lib/api/domains/claim-dot-link-domain";
+import { DubApiError } from "@/lib/api/errors";
import { parseRequestBody } from "@/lib/api/utils";
import { withWorkspace } from "@/lib/auth";
import { registerDomainSchema } from "@/lib/zod/schemas/domains";
import { NextResponse } from "next/server";
+// TODO: this logic is hard-coded for now, but we'll make it dynamic in the future
+const eligibleWorkspaces = [
+ "clrei1gld0002vs9mzn93p8ik",
+ "ws_1JT00MX4K1KQFMT2FEF6413XT",
+];
+
// POST /api/domains/register - register a domain
export const POST = withWorkspace(
async ({ workspace, session, req }) => {
const { domain } = registerDomainSchema.parse(await parseRequestBody(req));
+ if (!eligibleWorkspaces.includes(workspace.id)) {
+ throw new DubApiError({
+ code: "forbidden",
+ message:
+ "Your workspace is not eligible for domain registration. Contact [email protected] for more information.",
+ });
+ }
+
const response = await claimDotLinkDomain({
domain,
workspace,
diff --git a/apps/web/tests/domains/index.test.ts b/apps/web/tests/domains/index.test.ts
index a7fb1549a2..b3ff6f8639 100644
--- a/apps/web/tests/domains/index.test.ts
+++ b/apps/web/tests/domains/index.test.ts
@@ -109,7 +109,7 @@ describe.sequential("/domains/**", async () => {
test("GET /domains/status", async () => {
const domains = [
"getacme.link", // expected to be unavailable
- `acme${randomId(3).toLowerCase()}.link`, // expected to be available
+ `acme-${randomId(4).toLowerCase()}.link`, // expected to be available
];
const { status, data: domainStatuses } = await http.get<