You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/patterns/grouping-routes.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,16 @@ head:
7
7
8
8
- - meta
9
9
- name: 'description'
10
-
content: Grouping allows you to set prefix for multiple route once, with ".group". Suppose you have many paths with the same prefix instead of writing many same prefixes, you can group them using a single ".group" method
10
+
content: Grouping allows you to set prefixes for multiple routes at once, with ".group". Suppose you have many paths with the same prefix - instead of writing the same prefix multiple times, you can group them using a single ".group" method
11
11
12
12
- - meta
13
13
- property: 'og:description'
14
-
content: Grouping allows you to set prefix for multiple route once, with ".group". Suppose you have many paths with the same prefix instead of writing many same prefixes, you can group them using a single ".group" method
14
+
content: Grouping allows you to set prefixes for multiple routes at once, with ".group". Suppose you have many paths with the same prefix - instead of writing the same prefix multiple times, you can group them using a single ".group" method
15
15
---
16
16
17
-
# Group
17
+
# Grouping Routes
18
18
19
-
When creating a web server, you would often find multiple routes sharing the same prefix.
19
+
When creating a web server, you would often have multiple routes sharing the same prefix:
20
20
21
21
```typescript
22
22
newElysia()
@@ -26,7 +26,7 @@ new Elysia()
26
26
.listen(3000)
27
27
```
28
28
29
-
This can be improve with `Elysia.group`, allowing us to apply prefix to multiple routes a the same time by grouping them together.
29
+
This can be improved with `Elysia.group`, allowing us to apply prefixes to multiple routes at the same time by grouping them together:
30
30
31
31
```typescript
32
32
newElysia()
@@ -39,15 +39,15 @@ new Elysia()
39
39
.listen(3000)
40
40
```
41
41
42
-
This code behave the same as our first example and should response as follows:
42
+
This code behaves the same as our first example and should be structured as follows:
43
43
44
-
| Path | Result |
45
-
| -------- | ------- |
44
+
| Path | Result |
45
+
| -------------| ------- |
46
46
| /user/sign-in | Sign in |
47
-
| /user/sign-in| Sign up |
48
-
| /user/sign-in| Profile |
47
+
| /user/sign-up| Sign up |
48
+
| /user/profile| Profile |
49
49
50
-
Group can also accept an optional guard parameter to reduce boilerplate of using group and guard together.
50
+
`.group()` can also accept an optional guard parameter to reduce boilerplate of using groups and guards together:
51
51
52
52
```typescript
53
53
newElysia()
@@ -60,11 +60,11 @@ new Elysia()
60
60
.listen(3000)
61
61
```
62
62
63
-
You may find more information about grouped guard in [scope](/essential/scope.html).
63
+
You may find more information about grouped guards in [scope](/essential/scope.html).
64
64
65
-
## Prefix
65
+
## Prefixing
66
66
67
-
We can separate a group into a separate plugin instance to reduce nesting by providing **prefix** to constructor.
67
+
We can separate a group into a separate plugin instance to reduce nesting by providing a **prefix** to the constructor.
0 commit comments