@hyper-fetch/elysia 10.0.0 โ 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://hyperfetch.bettertyped.com/docs/integrations/elysia/overview"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/.github/assets/packages/elysia.png" alt="Hyper Fetch Elysia. Your Elysia app. Typed to every status. Bodies, queries, params and errors read from typeof app." /></a>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
5
|
<p align="center">
|
|
4
|
-
<
|
|
6
|
+
<a href="https://hyperfetch.bettertyped.com/docs/integrations/elysia/overview"><b>Quick Start</b></a> ยท
|
|
7
|
+
<a href="https://hyperfetch.bettertyped.com/docs/integrations/elysia/overview">Documentation</a> ยท
|
|
8
|
+
<a href="https://hyperfetch.bettertyped.com/docs/api/elysia/Types/ElysiaAppToHyperFetch">API Reference</a> ยท
|
|
9
|
+
<a href="https://github.com/BetterTyped/hyper-fetch">GitHub</a> ยท
|
|
10
|
+
<a href="https://discord.gg/7upC2kVmyM">Discord</a>
|
|
5
11
|
</p>
|
|
6
12
|
|
|
7
13
|
<p align="center">
|
|
8
|
-
<a href="https://github.com/BetterTyped/hyper-fetch">
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<a href="https://
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<a href="https://
|
|
15
|
-
<img src="https://img.shields.io/npm/dm/@hyper-fetch/elysia?logo=npm" alt="npm downloads" />
|
|
16
|
-
</a>
|
|
17
|
-
<a href="https://bundlephobia.com/package/@hyper-fetch/elysia">
|
|
18
|
-
<img src="https://img.shields.io/bundlephobia/minzip/@hyper-fetch/elysia?color=64BC4B" alt="bundle size" />
|
|
19
|
-
</a>
|
|
20
|
-
<a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md">
|
|
21
|
-
<img src="https://img.shields.io/github/license/BetterTyped/hyper-fetch?color=yellow" alt="license" />
|
|
22
|
-
</a>
|
|
23
|
-
<a href="https://github.com/BetterTyped/hyper-fetch">
|
|
24
|
-
<img src="https://img.shields.io/badge/typescript-%23007ACC.svg?logo=typescript&logoColor=white" alt="TypeScript" />
|
|
25
|
-
</a>
|
|
26
|
-
<a href="https://elysiajs.com/">
|
|
27
|
-
<img src="https://img.shields.io/badge/elysia-8A2BE2" alt="Elysia" />
|
|
28
|
-
</a>
|
|
14
|
+
<a href="https://github.com/BetterTyped/hyper-fetch"><img src="https://img.shields.io/github/stars/BetterTyped/hyper-fetch?style=flat&logo=github&color=333" alt="GitHub stars" /></a>
|
|
15
|
+
<a href="https://www.npmjs.com/package/@hyper-fetch/elysia"><img src="https://img.shields.io/npm/v/@hyper-fetch/elysia?logo=npm&color=e76f51" alt="npm version" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@hyper-fetch/elysia"><img src="https://api.maciejpyrc.com/portfolio/npm/downloads.svg?packages=@hyper-fetch/elysia&color=fbc646" alt="Monthly downloads" /></a>
|
|
17
|
+
<a href="https://bundlejs.com/?q=@hyper-fetch/elysia"><img src="https://api.maciejpyrc.com/portfolio/npm/size.svg?package=@hyper-fetch/elysia&external=@hyper-fetch/core,elysia" alt="Bundle size" /></a>
|
|
18
|
+
<a href="https://github.com/BetterTyped/hyper-fetch"><img src="https://img.shields.io/badge/TypeScript-strict-3178C6?logo=typescript&logoColor=white" alt="TypeScript" /></a>
|
|
19
|
+
<a href="https://hyperfetch.bettertyped.com/docs/integrations/elysia/overview"><img src="https://img.shields.io/badge/Elysia-1.3%2B-C084FC" alt="Integration" /></a>
|
|
20
|
+
<a href="https://github.com/BetterTyped/hyper-fetch/blob/main/License.md"><img src="https://img.shields.io/github/license/BetterTyped/hyper-fetch?color=blue" alt="License" /></a>
|
|
29
21
|
</p>
|
|
30
22
|
|
|
31
23
|
## ๐ About
|
|
32
24
|
|
|
33
|
-
`@hyper-fetch/elysia` turns the type of an Elysia app into a
|
|
25
|
+
`@hyper-fetch/elysia` turns the type of an Elysia app into a Hyper Fetch SDK schema. Your frontend calls the backend
|
|
34
26
|
through `createSdk` with response, error, payload, query and param types read straight from your Elysia routes and
|
|
35
27
|
schemas. It ships types only, so nothing from your server ends up in the client bundle.
|
|
36
28
|
|
|
@@ -39,12 +31,11 @@ schemas. It ships types only, so nothing from your server ends up in the client
|
|
|
39
31
|
- ๐ **Backend types, frontend calls** - Change an Elysia route and every SDK call that uses it fails to compile
|
|
40
32
|
- ๐งญ **Paths become properties** - `/users/:userId/posts` is `sdk.users.$userId.posts.$get`, with typed `setParams()`
|
|
41
33
|
- ๐ **Schemas drive the inputs** - `body` and `query` schemas type `setPayload()` and `setQueryParams()`
|
|
42
|
-
- ๐ฆ **Typed errors per status** - 2xx bodies type `data
|
|
43
|
-
|
|
44
|
-
- ๐ก **Types match the wire** - Dates arrive as strings, file bodies are `FormData`, and streams stay `unknown`
|
|
34
|
+
- ๐ฆ **Typed errors per status** - 2xx bodies type `data`. Every other status, `422` validation errors included, types `error`
|
|
35
|
+
- ๐ก **Types match the wire** - Dates arrive as strings, file bodies are `FormData` and streams stay `unknown`
|
|
45
36
|
- ๐งฉ **Plugins included** - `prefix`, `.group()`, `.guard()`, `.model()` and macros land in the endpoint and the types
|
|
46
37
|
- ๐ชถ **Zero runtime** - A single type export, so it adds no code to your bundle
|
|
47
|
-
- โก **Every HyperFetch feature** - Cache, retries, deduplication, offline and React hooks
|
|
38
|
+
- โก **Every HyperFetch feature** - Cache, retries, deduplication, offline replay and React hooks on every route
|
|
48
39
|
|
|
49
40
|
## ๐ Quick Start
|
|
50
41
|
|
|
@@ -75,9 +66,10 @@ const { data } = await sdk.users.$userId.$get.setParams({ userId: "1" }).send();
|
|
|
75
66
|
|
|
76
67
|
## ๐ Documentation
|
|
77
68
|
|
|
78
|
-
- [Elysia Integration
|
|
79
|
-
- [SDK
|
|
80
|
-
- [Getting Started](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)
|
|
69
|
+
- **[Elysia Integration](https://hyperfetch.bettertyped.com/docs/integrations/elysia/overview)** - Setup, schemas, errors and plugins
|
|
70
|
+
- **[SDK](https://hyperfetch.bettertyped.com/docs/core/sdk)** - How `createSdk` turns a schema into requests
|
|
71
|
+
- **[Getting Started](https://hyperfetch.bettertyped.com/docs/getting-started/quick-start)** - The core request API
|
|
72
|
+
- **[API Reference](https://hyperfetch.bettertyped.com/docs/api/elysia/Types/ElysiaAppToHyperFetch)** - Every exported type
|
|
81
73
|
|
|
82
74
|
## ๐ก Examples
|
|
83
75
|
|
|
@@ -105,6 +97,7 @@ export type AppSchema = ElysiaAppToHyperFetch<typeof app>;
|
|
|
105
97
|
```ts
|
|
106
98
|
const sdk = createSdk<typeof client, AppSchema>(client);
|
|
107
99
|
|
|
100
|
+
// the payload is typed by t.Object({ name: t.String() })
|
|
108
101
|
await sdk.users.$post.setPayload({ name: "Bob" }).send();
|
|
109
102
|
|
|
110
103
|
const { data, error } = await sdk.users.$userId.$get.setParams({ userId: "missing" }).send();
|
|
@@ -122,13 +115,45 @@ import { useFetch } from "@hyper-fetch/react";
|
|
|
122
115
|
import { sdk } from "./api";
|
|
123
116
|
|
|
124
117
|
export const UserName = ({ userId }: { userId: string }) => {
|
|
125
|
-
const { data, loading } = useFetch(sdk.users.$userId.$get.setParams({ userId }));
|
|
118
|
+
const { data, error, loading } = useFetch(sdk.users.$userId.$get.setParams({ userId }));
|
|
126
119
|
|
|
127
|
-
if (loading) return <
|
|
120
|
+
if (loading) return <Spinner />;
|
|
121
|
+
if (error) return <p>Could not load the user</p>;
|
|
128
122
|
return <p>{data?.name}</p>;
|
|
129
123
|
};
|
|
130
124
|
```
|
|
131
125
|
|
|
126
|
+
## ๐งฉ Hyper Fetch Ecosystem
|
|
127
|
+
|
|
128
|
+
One typed client for every backend. Swap the adapter and keep the same `createRequest()` everywhere.
|
|
129
|
+
|
|
130
|
+
<table align="center">
|
|
131
|
+
<tr>
|
|
132
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/core"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-hyper-fetch.svg" width="36" height="36" alt="" /><br /><sub><b>Core</b></sub></a></td>
|
|
133
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/react"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-react.svg" width="36" height="36" alt="" /><br /><sub><b>React</b></sub></a></td>
|
|
134
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/sockets"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-sockets.svg" width="36" height="36" alt="" /><br /><sub><b>Sockets</b></sub></a></td>
|
|
135
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/cli"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-openapi.svg" width="36" height="36" alt="" /><br /><sub><b>OpenAPI CLI</b></sub></a></td>
|
|
136
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-graphql"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-graphql.svg" width="36" height="36" alt="" /><br /><sub><b>GraphQL</b></sub></a></td>
|
|
137
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-trpc"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-trpc.svg" width="36" height="36" alt="" /><br /><sub><b>tRPC</b></sub></a></td>
|
|
138
|
+
</tr>
|
|
139
|
+
<tr>
|
|
140
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-orpc"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-orpc-dark.svg" /><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-orpc.svg" width="36" height="36" alt="" /></picture><br /><sub><b>oRPC</b></sub></a></td>
|
|
141
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/hono"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-hono.svg" width="36" height="36" alt="" /><br /><sub><b>Hono</b></sub></a></td>
|
|
142
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/elysia"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-elysia.svg" width="36" height="36" alt="" /><br /><sub><b>Elysia</b></sub></a></td>
|
|
143
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-firebase"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-firebase.svg" width="36" height="36" alt="" /><br /><sub><b>Firebase</b></sub></a></td>
|
|
144
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/adapter-axios"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/integration-axios.svg" width="36" height="36" alt="" /><br /><sub><b>Axios</b></sub></a></td>
|
|
145
|
+
<td align="center" width="110"><a href="https://github.com/BetterTyped/hyper-fetch/tree/main/packages/hyper-flow"><img src="https://raw.githubusercontent.com/BetterTyped/hyper-fetch/main/documentation/static/img/hyper-flow.svg" width="36" height="36" alt="" /><br /><sub><b>HyperFlow</b></sub></a></td>
|
|
146
|
+
</tr>
|
|
147
|
+
</table>
|
|
148
|
+
|
|
149
|
+
## ๐ Sponsors
|
|
150
|
+
|
|
151
|
+
<p align="center">
|
|
152
|
+
<a href="https://github.com/sponsors/prc5">
|
|
153
|
+
<img src="https://raw.githubusercontent.com/prc5/sponsors/main/packages/other/sponsorkit/sponsors.svg?raw=true" alt="Sponsors" />
|
|
154
|
+
</a>
|
|
155
|
+
</p>
|
|
156
|
+
|
|
132
157
|
## License
|
|
133
158
|
|
|
134
159
|
[Apache-2.0](https://github.com/BetterTyped/hyper-fetch/blob/main/License.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyper-fetch/elysia",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"description": "Turn an Elysia app type into a fully typed Hyper Fetch SDK schema",
|
|
5
5
|
"author": "Maciej Pyrc <maciekpyrc@gmail.com>, Kacper Skawina <kacper.skawina@gmail.com>",
|
|
6
6
|
"homepage": "https://hyperfetch.bettertyped.com/",
|