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.

add script

Steven Tey3de60ed167f9
diff --git a/apps/web/app/(ee)/api/track/open/route.ts b/apps/web/app/(ee)/api/track/open/route.ts
index 9e6efa64e3..c67b279ece 100644
--- a/apps/web/app/(ee)/api/track/open/route.ts
+++ b/apps/web/app/(ee)/api/track/open/route.ts
@@ -56,8 +56,6 @@ export const POST = withAxiom(async (req: AxiomRequest) => {
// else, reuse the cached clickId
const clickId = cachedClickId ?? nanoid(16);
- console.log({ deepLink, cachedClickId, cachedLink });
-
if (!cachedLink) {
const link = await getLinkViaEdge({
domain,
diff --git a/apps/web/scripts/annature/import-domains.ts b/apps/web/scripts/annature/import-domains.ts
new file mode 100644
index 0000000000..994cdd8590
--- /dev/null
+++ b/apps/web/scripts/annature/import-domains.ts
@@ -0,0 +1,81 @@
+import { createId } from "@/lib/api/create-id";
+import { addDomainToVercel } from "@/lib/api/domains/add-domain-vercel";
+import { configureVercelNameservers } from "@/lib/api/domains/configure-vercel-nameservers";
+import { prisma } from "@dub/prisma";
+import { linkConstructorSimple } from "@dub/utils";
+import "dotenv-flow/config";
+
+async function main() {
+ const projectId = "xxx";
+ const userId = "xxx";
+ const domainList = [];
+
+ const domains = await prisma.domain.createMany({
+ data: domainList.map((d) => ({
+ id: createId({ prefix: "dom_" }),
+ slug: d,
+ projectId,
+ })),
+ skipDuplicates: true,
+ });
+
+ console.log(`Created ${domains.count} domains`);
+
+ const createdDomains = await prisma.domain.findMany({
+ where: {
+ slug: {
+ in: domainList,
+ },
+ },
+ });
+
+ const registeredDomains = await prisma.registeredDomain.createMany({
+ data: domainList.map((d) => ({
+ slug: d,
+ projectId,
+ domainId: createdDomains.find((cd) => cd.slug === d)?.id,
+ expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
+ })),
+ skipDuplicates: true,
+ });
+
+ console.log({ registeredDomains });
+
+ const links = await prisma.link.createMany({
+ data: domainList.map((d) => ({
+ id: createId({ prefix: "link_" }),
+ domain: d,
+ key: "_root",
+ url: "",
+ shortLink: linkConstructorSimple({ domain: d, key: "_root" }),
+ userId,
+ projectId,
+ })),
+ skipDuplicates: true,
+ });
+
+ console.log(`Created ${links.count} links`);
+
+ // const tbLinks = await prisma.link.findMany({
+ // where: {
+ // domain: {
+ // in: domainList,
+ // },
+ // },
+ // });
+
+ // const tbResponse = await recordLink(tbLinks);
+
+ // console.log({ tbResponse });
+
+ await Promise.all(
+ domainList.slice(100, 125).map(async (d) => {
+ const addRes = await addDomainToVercel(d);
+ console.log({ addRes });
+ const nsRes = await configureVercelNameservers(d);
+ console.log({ nsRes });
+ }),
+ );
+}
+
+main();