Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elysiajs/elysia-trpc
A plugin for Elysia that add support for using tRPC
https://github.com/elysiajs/elysia-trpc
Last synced: 3 months ago
JSON representation
A plugin for Elysia that add support for using tRPC
- Host: GitHub
- URL: https://github.com/elysiajs/elysia-trpc
- Owner: elysiajs
- License: mit
- Created: 2022-12-06T17:36:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T11:57:26.000Z (4 months ago)
- Last Synced: 2024-07-29T11:34:21.194Z (4 months ago)
- Language: TypeScript
- Size: 181 KB
- Stars: 18
- Watchers: 1
- Forks: 16
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-elysia - trpc - Plugin that add support for using tRPC. (Plugins)
README
# @elysiajs/trpc
A plugin for [elysia](https://github.com/elysiajs/elysia) that adds support for using tRPC.## Installation
```bash
bun add @elysiajs/trpc
```## Example
```typescript
import { Elysia, t } from 'elysia'
import { trpc, compile as c } from '@elysiajs/trpc'import { initTRPC } from '@trpc/server'
const r = initTRPC.create()
const router = r.router({
greet: r.procedure.input(c(t.String())).query(({ input }) => input)
})export type Router = typeof router
const app = new Elysia()
.use(trpc(router))
.listen(8080)
```## API
This plugin extends the new method `trpc` to `Elysia` class.### trpc
Register tRPC router.```typescript
type tRPC = (router: Router, options?: TRPCOptions) => thisexport interface TRPCOptions
extends Omit<
FetchHandlerRequestOptions,
'req' | 'router' | 'endpoint'
> {
/**
* tRPC endpoint
*
* @default '/trpc'
*/
endpoint?: string
}
```## Note
WebSocket API is in an experimental state and unstable.Is meant for experimental for better stabilization.