From f5ef5ac97de772858c91aca6bb943dace4f46153 Mon Sep 17 00:00:00 2001 From: Luis Cadillo Date: Thu, 23 May 2024 08:03:33 -0500 Subject: [PATCH] docs(trpc): add custom endpoint configuration example (#538) This PR adds documentation for configuring custom endpoints with the @hono/trpc-server middleware. Ensuring the endpoint parameter matches the middleware's path helps avoid issues like the one described in [honojs/middleware#166](https://github.com/honojs/middleware/issues/166). --- packages/trpc-server/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/trpc-server/README.md b/packages/trpc-server/README.md index b04cb52b..34b65d65 100644 --- a/packages/trpc-server/README.md +++ b/packages/trpc-server/README.md @@ -112,6 +112,28 @@ app.use( }) ) ``` +## Custom Endpoints + +To set up custom endpoints ensure the endpoint parameter matches the middleware's path. This alignment allows `@trpc/server` to accurately extract your procedure paths. + +```ts +import { Hono } from 'hono' +import { trpcServer } from '@hono/trpc-server' +import { appRouter } from './router' + +const app = new Hono() + +// Custom endpoint configuration +app.use( + '/api/trpc/*', + trpcServer({ + endpoint: '/api/trpc', + router: appRouter, + }) +) + +export default app +``` ## Author