Skip to content

Instantly share code, notes, and snippets.

@alex-streza
Last active February 14, 2024 14:49
Show Gist options
  • Save alex-streza/33ea9f06ad7dfb587a84e267e385c7c6 to your computer and use it in GitHub Desktop.
Save alex-streza/33ea9f06ad7dfb587a84e267e385c7c6 to your computer and use it in GitHub Desktop.
Next.js App Router - trpc-openapi
// /app/api/[...trpc]/route.ts
/**
"trpc-openapi": "^1.2.0",
"@trpc/client": "next",
"@trpc/next": "next",
"@trpc/react-query": "next",
"@trpc/server": "next",
**/
import { createOpenApiNextHandler } from "trpc-openapi";
import { appRouter } from "@morrow/api";
import { createTRPCOpenAPIContext } from "@morrow/api/src/trpc";
const handler = createOpenApiNextHandler({
router: appRouter,
createContext: createTRPCOpenAPIContext,
onError: undefined,
responseMeta: undefined,
});
export { handler as GET, handler as POST };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment