Skip to content

Commit e04d1fc

Browse files
authored
Merge pull request #314 from mewxz029/fix/scope-response-example
fix: essential/scope response example
2 parents bcdd529 + 14fe949 commit e04d1fc

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

docs/essential/scope.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ const demo2 = new Elysia()
3333
.use(plugin2)
3434
.get('/parent', () => 'parent')
3535

36+
const mock2 = {
37+
'/child': {
38+
'GET': 'hi'
39+
},
40+
'/parent': {
41+
'GET': 'hi'
42+
}
43+
}
44+
3645
const plugin3 = new Elysia()
3746
.onBeforeHandle({ as: 'global' }, () => {
3847
return 'overwrite'
@@ -44,6 +53,15 @@ const demo3 = new Elysia()
4453
.get('/inner', () => 'inner')
4554
)
4655
.get('/outer', () => 'outer')
56+
57+
const mock3 = {
58+
'/inner': {
59+
'GET': 'overwrite'
60+
},
61+
'/outer': {
62+
'GET': 'outer'
63+
}
64+
}
4765
</script>
4866

4967
By default, hook and schema is scope to current instance only not global.
@@ -203,7 +221,7 @@ const app = new Elysia()
203221
.listen(3000)
204222
```
205223

206-
<Playground :elysia="demo3" />
224+
<Playground :elysia="demo3" :mock="mock3" />
207225

208226
Evaluating the route, should logs as follows:
209227
| route | response |
@@ -309,4 +327,4 @@ const main = new Elysia()
309327
.get('/parent', () => 'parent')
310328
```
311329

312-
<Playground :elysia="demo2" />
330+
<Playground :elysia="demo2" :mock="mock2" />

0 commit comments

Comments
 (0)