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: 11 days 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 (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-16T11:57:26.000Z (5 months ago)
- Last Synced: 2024-11-30T07:34:02.098Z (14 days ago)
- Language: TypeScript
- Size: 181 KB
- Stars: 22
- Watchers: 1
- Forks: 18
- Open Issues: 14
-
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.