The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Merge branch 'main' into tim/multiple-tags-cleanup
Steven Teyab58682402af
diff --cc apps/web/app/api/links/[linkId]/route.tsindex 6506574813,953d6f5cbe..3ab2def61c--- a/apps/web/app/api/links/[linkId]/route.ts+++ b/apps/web/app/api/links/[linkId]/route.ts@@@ -1,8 -1,8 +1,8 @@@import { DubApiError, ErrorCodes } from "@/lib/api/errors";import { deleteLink, editLink, processLink } from "@/lib/api/links";- import { withAuth } from "@/lib/auth";+ import { withWorkspace } from "@/lib/auth";import prisma from "@/lib/prisma";-import { LinkWithTagIdsProps } from "@/lib/types";+import { NewLinkProps } from "@/lib/types";import { updateLinkBodySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";diff --cc apps/web/app/api/links/bulk/route.tsindex 66e3b31d8c,993245be4a..d01a6b99b9--- a/apps/web/app/api/links/bulk/route.ts+++ b/apps/web/app/api/links/bulk/route.ts@@@ -1,8 -1,8 +1,8 @@@import { DubApiError, exceededLimitError } from "@/lib/api/errors";import { bulkCreateLinks, combineTagIds, processLink } from "@/lib/api/links";- import { withAuth } from "@/lib/auth";+ import { withWorkspace } from "@/lib/auth";import prisma from "@/lib/prisma";-import { LinkWithTagIdsProps } from "@/lib/types";+import { ProcessedLinkProps } from "@/lib/types";import { bulkCreateLinksBodySchema } from "@/lib/zod/schemas";import { NextResponse } from "next/server";diff --cc apps/web/app/api/links/route.tsindex 5a9ac6df55,574ae6fb47..abbdbd55d3--- a/apps/web/app/api/links/route.ts+++ b/apps/web/app/api/links/route.ts@@@ -1,49 -1,48 +1,47 @@@import { DubApiError, ErrorCodes } from "@/lib/api/errors";import { createLink, getLinksForWorkspace, processLink } from "@/lib/api/links";- import { withAuth } from "@/lib/auth";+ import { withWorkspace } from "@/lib/auth";-import { LinkWithTagIdsProps } from "@/lib/types";import { ratelimit } from "@/lib/upstash";import { createLinkBodySchema, getLinksQuerySchema } from "@/lib/zod/schemas";-import { LOCALHOST_IP } from "@dub/utils";+import { LOCALHOST_IP, getSearchParamsWithArray } from "@dub/utils";import { NextResponse } from "next/server";// GET /api/links – get all links for a workspace- export const GET = withAuth(async ({ req, headers, workspace }) => {-export const GET = withWorkspace(- async ({ headers, searchParams, workspace }) => {- const {- domain,- tagId,- tagIds,- search,- sort,- page,- userId,- showArchived,- withTags,- } = getLinksQuerySchema.parse(searchParams);++export const GET = withWorkspace(async ({ req, headers, workspace }) => {+ const searchParams = getSearchParamsWithArray(req.url);- const response = await getLinksForWorkspace({- workspaceId: workspace.id,- domain,- tagId,- tagIds,- search,- sort,- page,- userId,- showArchived,- withTags,- });+ const {+ domain,+ tagId,+ tagIds,- tagNames,+ search,+ sort,+ page,+ userId,+ showArchived,+ withTags,+ } = getLinksQuerySchema.parse(searchParams);- return NextResponse.json(response, {- headers,- });- },-);+ const response = await getLinksForWorkspace({+ workspaceId: workspace.id,+ domain,+ tagId,+ tagIds,- tagNames,+ search,+ sort,+ page,+ userId,+ showArchived,+ withTags,+ });++ return NextResponse.json(response, {+ headers,+ });+});// POST /api/links – create a new link- export const POST = withAuth(+ export const POST = withWorkspace(async ({ req, headers, session, workspace }) => {let bodyRaw;try {