blob: a324d498f84fc856d40c15513fd2e189ce4e30fc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
import { NextRequest } from "next/server";
import { buildHandler } from "@/app/api/v1/utils/handler";
import { zNewHighlightSchema } from "@hoarder/shared/types/highlights";
import { adaptPagination, zPagination } from "../utils/pagination";
export const dynamic = "force-dynamic";
export const GET = (req: NextRequest) =>
buildHandler({
req,
searchParamsSchema: zPagination,
handler: async ({ api, searchParams }) => {
const resp = await api.highlights.getAll({
...searchParams,
});
return { status: 200, resp: adaptPagination(resp) };
},
});
export const POST = (req: NextRequest) =>
buildHandler({
req,
bodySchema: zNewHighlightSchema,
handler: async ({ body, api }) => {
const resp = await api.highlights.create(body!);
return { status: 201, resp };
},
});
|