Skip to content

Commit 31130a9

Browse files
committed
📘 doc: update vitepress to 1, mention method chaining
1 parent cd536a8 commit 31130a9

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

bun.lockb

100644100755
19.5 KB
Binary file not shown.

docs/.vitepress/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ export default defineConfig({
260260
collapsed: true,
261261
items: [
262262
{
263-
text: 'Grouping Routes',
264-
link: '/patterns/grouping-routes'
263+
text: 'Group',
264+
link: '/patterns/group'
265265
},
266266
{
267267
text: 'Cookie',

docs/essential/route.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,29 @@ Elysia HTTP methods accepts the following parameters:
8585

8686
You can read more about the HTTP methods on [HTTP Request Methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods).
8787

88+
## Method Chaining
89+
Rule of thumb, **ALWAYS** use method chaining in Elysia.
90+
91+
```typescript
92+
import { Elysia } from 'elysia'
93+
94+
// ❌ don't
95+
const app = new Elysia()
96+
97+
app.get('/', () => 'hello')
98+
99+
app.post('/', () => 'world')
100+
101+
// ✅ do
102+
const app = new Elysia()
103+
.get('/', () => 'hello')
104+
.post('/', () => 'world')
105+
```
106+
107+
Elysia is using method chaining to synchronize type safety for later use.
108+
109+
Without method chaining, Elysia can't ensure your type integrity which will have of usage in later chapters.
110+
88111
## Handle
89112

90113
Most developers use REST clients like Postman, Insomnia or Hoppscotch to test their API.
@@ -151,7 +174,9 @@ Elysia provides an `Elysia.all` for handling any HTTP method for a specified pat
151174
```typescript
152175
import { Elysia } from 'elysia'
153176

154-
new Elysia().all('/', () => 'hi').listen(3000)
177+
new Elysia()
178+
.all('/', () => 'hi')
179+
.listen(3000)
155180
```
156181

157182
Any HTTP method that matches the path, will be handled as follows:
File renamed without changes.

docs/table-of-content.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ There's no correct way to learn Elysia, but we recommended **completing the esse
3232
<Card title="Life Cycle" href="/life-cycle/overview">
3333
Intercept events and customize behaviors
3434
</Card>
35-
<Card title="Patterns" href="/patterns/cookie">
35+
<Card title="Patterns" href="/patterns/group">
3636
Common patterns and best practices
3737
</Card>
3838
<Card title="Plugin" href="/plugins/overview">

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
"flexsearch": "^0.7.31",
3535
"markdown-it": "^13.0.2",
3636
"view-transitions-api-types": "^0.1.1",
37-
"vitepress": "1.0.0-rc.29",
38-
"vue": "^3.3.8"
37+
"vitepress": "^1.0.1",
38+
"vue": "^3.4.21"
3939
},
4040
"scripts": {
4141
"dev": "vitepress dev docs",

0 commit comments

Comments
 (0)