Created
March 31, 2023 03:10
-
-
Save WoLfulus/5892e1f87acf0dd600bdc3c09cdecd9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { z } from "zod"; | |
import { query } from "@/lib/api/middlewares/with-query"; | |
import { responses } from "@/lib/api/responses"; | |
import { get, route } from "@/lib/api/route"; | |
import { locales } from "@/server/middlewares/with-locales"; | |
import { db } from "@/server/middlewares/with-db"; | |
export const { GET } = route( | |
get() | |
.use( | |
query({ | |
count: z.coerce.number().min(1).max(10).default(5), | |
}) | |
) | |
.use(db()) | |
.use(locales()) | |
.handler(async ({ query, db, locales }) => { | |
return responses.json( | |
await db.news.highlights(query.count, locales) | |
); | |
}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment