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).
pull/542/head
Luis Cadillo 2024-05-23 08:03:33 -05:00 committed by GitHub
parent a595e4e260
commit f5ef5ac97d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 22 additions and 0 deletions

View File

@ -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 ## Author