Skip to content

Commit

Permalink
docs(trpc): add custom endpoint configuration example (#538)
Browse files Browse the repository at this point in the history
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 [#166](#166).
  • Loading branch information
luiisca authored May 23, 2024
1 parent a595e4e commit f5ef5ac
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/trpc-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f5ef5ac

Please sign in to comment.