Skip to content

Commit 6b69c7e

Browse files
committed
📘 feat: rewrite e2e type-safety block
1 parent 47e24ce commit 6b69c7e

File tree

3 files changed

+60
-29
lines changed

3 files changed

+60
-29
lines changed

‎components/midori/e2e-type-safety.vue

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,50 +32,33 @@ await eden.user.age.patch({
3232
</script>
3333

3434
<template>
35-
<section
36-
class="flex flex-col justify-center items-center w-full max-w-6xl mx-auto py-4"
37-
>
35+
<section class="flex flex-col justify-center items-center w-full max-w-6xl mx-auto py-4">
3836
<!-- <h3 class="text-2xl mr-auto md:mx-auto font-medium text-gray-400">
3937
Introducing
4038
</h3> -->
4139
<h2
42-
class="text-5xl md:text-6xl font-bold !leading-tight text-transparent bg-clip-text bg-gradient-to-r from-sky-300 to-indigo-400 mb-6 mr-auto md:mx-auto"
43-
>
40+
class="text-5xl md:text-6xl font-bold !leading-tight text-transparent bg-clip-text bg-gradient-to-r from-sky-300 to-indigo-400 mb-6 mr-auto md:mx-auto">
4441
End–to-End Type Safety
4542
</h2>
4643

47-
<p
48-
class="text-xl md:text-2xl leading-relaxed text-gray-400 text-left md:text-center w-full max-w-2xl"
49-
>
44+
<p class="text-xl md:text-2xl leading-relaxed text-gray-400 text-left md:text-center w-full max-w-2xl">
5045
Synchronize types across all applications.
5146
<br />
5247
Move fast and break nothing like tRPC.
5348
</p>
5449

55-
<a
56-
class="text-lg font-medium bg-blue-50 text-blue-500 dark:text-blue-400 dark:bg-blue-500/20 mr-auto md:mx-auto px-4 py-2 rounded-xl mt-6"
57-
href="/eden/overview"
58-
>
50+
<a class="text-lg font-medium bg-blue-50 text-blue-500 dark:text-blue-400 dark:bg-blue-500/20 mr-auto md:mx-auto px-4 py-2 rounded-xl mt-6"
51+
href="/eden/overview">
5952
See how it works
6053
</a>
6154

6255
<section class="flex flex-col lg:flex-row gap-8 w-full max-w-5xl my-8">
63-
<div class="w-full">
64-
<Prism
65-
class="!text-base !font-mono rounded-xl"
66-
language="typescript"
67-
>
68-
{{ server }}
69-
</Prism>
56+
<div class="w-full !text-base !font-mono rounded-xl">
57+
<slot name="server">test</slot>
7058
</div>
71-
<div class="relative w-full">
72-
<Prism
73-
class="!text-base !font-mono rounded-xl"
74-
language="typescript"
75-
>
76-
{{ client }}
77-
</Prism>
78-
<div
59+
<div class="relative w-full !text-base !font-mono rounded-xl">
60+
<slot name="client"></slot>
61+
<!-- <div
7962
class="absolute p-1 rounded bg-red-400/25"
8063
style="
8164
top: 13.5em;
@@ -89,7 +72,7 @@ await eden.user.age.patch({
8972
style="top: 15.25em; left: 3.25em"
9073
>
9174
Type 'string' is not assignable to type 'number'
92-
</p>
75+
</p> -->
9376
</div>
9477
</section>
9578
</section>

‎components/midori/index.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ const isDark = useDark()
5959
<slot name="openapi"></slot>
6060
</OpenAPI>
6161
</section>
62-
<E2ETypeSafety />
62+
<E2ETypeSafety>
63+
<template v-slot:server>
64+
<slot name="server"></slot>
65+
</template>
66+
<template v-slot:client>
67+
<slot name="client"></slot>
68+
</template>
69+
</E2ETypeSafety>
6370
<Plugins />
6471
<Editor />
6572
<Community />

‎docs/index.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,46 @@ new Elysia()
7171
.listen(3000)
7272
```
7373
</template>
74+
75+
<template v-slot:server>
76+
77+
```ts
78+
// server.ts
79+
import { Elysia, t } from 'elysia'
80+
81+
const app = new Elysia()
82+
.patch(
83+
'/user/age',
84+
({ body }) => signIn(body),
85+
{
86+
body: t.Object({
87+
name: t.String(),
88+
age: t.Number()
89+
})
90+
}
91+
)
92+
.listen(80)
93+
94+
export type App = typeof app
95+
```
96+
</template>
97+
98+
<template v-slot:client>
99+
100+
```ts
101+
// client.ts
102+
import { edenTreaty } from '@elysiajs/eden'
103+
import type { App } from 'server'
104+
105+
const eden = edenTreaty<App>('http://localhost')
106+
107+
await eden.user.age.patch({
108+
name: 'saltyaom',
109+
age: '21'
110+
})
111+
```
112+
</template>
113+
114+
74115
</Landing>
75116
```

0 commit comments

Comments
 (0)