Skip to content

Instantly share code, notes, and snippets.

@WoLfulus
Created March 31, 2023 03:10
Show Gist options
  • Save WoLfulus/5892e1f87acf0dd600bdc3c09cdecd9a to your computer and use it in GitHub Desktop.
Save WoLfulus/5892e1f87acf0dd600bdc3c09cdecd9a to your computer and use it in GitHub Desktop.
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