Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elysiajs/eden
Fully type-safe Elysia client
https://github.com/elysiajs/eden
Last synced: 11 days ago
JSON representation
Fully type-safe Elysia client
- Host: GitHub
- URL: https://github.com/elysiajs/eden
- Owner: elysiajs
- License: mit
- Created: 2022-12-12T16:39:43.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-10T00:29:57.000Z (7 months ago)
- Last Synced: 2024-05-10T18:57:06.717Z (7 months ago)
- Language: TypeScript
- Size: 3.24 MB
- Stars: 106
- Watchers: 1
- Forks: 33
- Open Issues: 34
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-elysia - eden - Fully type-safe client. (Plugins)
README
# @elysiajs/eden
Fully type-safe Elysia client refers to the [documentation](https://elysiajs.com/eden/overview)## Installation
```bash
bun add elysia @elysiajs/eden
```## Example
```typescript
// server.ts
import { Elysia, t } from 'elysia'const app = new Elysia()
.get('/', () => 'Hi Elysia')
.get('/id/:id', ({ params: { id } }) => id)
.post('/mirror', ({ body }) => body, {
schema: {
body: t.Object({
id: t.Number(),
name: t.String()
})
}
})
.listen(8080)export type App = typeof app
// client.ts
import { edenTreaty } from '@elysiajs/eden'
import type { App } from './server'const app = edenTreaty('http://localhost:8080')
// data: Hi Elysia (fully type-safe)
const { data: pong } = app.index.get()// data: 1895
const { data: id } = client.id.1895.get()// data: { id: 1895, name: 'Skadi' }
const { data: nendoroid } = app.mirror.post({
id: 1895,
name: 'Skadi'
})
```