From ba89a864bb4548623ca1bfcfc9ab6eb7fe782603 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Wed, 16 Apr 2025 19:04:25 +0000 Subject: fix: Add includeContent to search endpoint and document it in the docs --- apps/web/app/api/v1/bookmarks/search/route.ts | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'apps/web/app/api') diff --git a/apps/web/app/api/v1/bookmarks/search/route.ts b/apps/web/app/api/v1/bookmarks/search/route.ts index f0c5417a..52081c7f 100644 --- a/apps/web/app/api/v1/bookmarks/search/route.ts +++ b/apps/web/app/api/v1/bookmarks/search/route.ts @@ -2,29 +2,33 @@ import { NextRequest } from "next/server"; import { z } from "zod"; import { buildHandler } from "../../utils/handler"; +import { zGetBookmarkSearchParamsSchema } from "../../utils/types"; export const dynamic = "force-dynamic"; export const GET = (req: NextRequest) => buildHandler({ req, - searchParamsSchema: z.object({ - q: z.string(), - limit: z.coerce.number().optional(), - cursor: z - .string() - // Search cursor V1 is just a number - .pipe(z.coerce.number()) - .transform((val) => { - return { ver: 1 as const, offset: val }; - }) - .optional(), - }), + searchParamsSchema: z + .object({ + q: z.string(), + limit: z.coerce.number().optional(), + cursor: z + .string() + // Search cursor V1 is just a number + .pipe(z.coerce.number()) + .transform((val) => { + return { ver: 1 as const, offset: val }; + }) + .optional(), + }) + .and(zGetBookmarkSearchParamsSchema), handler: async ({ api, searchParams }) => { const bookmarks = await api.bookmarks.searchBookmarks({ text: searchParams.q, cursor: searchParams.cursor, limit: searchParams.limit, + includeContent: searchParams.includeContent, }); return { status: 200, -- cgit v1.2.3-70-g09d2