Skip to content

Commit 6626099

Browse files
committed
docs(key-concept): use string status names for auth examples
- Change status(401) to status("Unauthorized") for clarity - Remove '// or' comments from auth examples
1 parent 00b0902 commit 6626099

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

docs/essential/life-cycle.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const demo = new Elysia()
2828
})
2929
.get('/throw', ({ status }) => {
3030
// This will be caught by onError
31-
throw status(418) // or status("I'm a teapot")
31+
throw status(418)
3232
})
3333
.get('/return', ({ status }) => {
3434
// This will NOT be caught by onError
35-
return status(418) // or status("I'm a teapot")
35+
return status(418)
3636
})
3737
</script>
3838

docs/key-concept.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ import { Elysia } from 'elysia'
1919
import Playground from './components/nearl/playground.vue'
2020

2121
const profile1 = new Elysia()
22-
.onBeforeHandle(({ status }) => status(401))
23-
.get('/profile', ({ status }) => status(401))
22+
.onBeforeHandle(({ status }) => status("Unauthorized"))
23+
.get('/profile', ({ status }) => status("Unauthorized"))
2424

2525
const demo1 = new Elysia()
2626
.use(profile1)
2727
// This will NOT have sign in check
2828
.patch('/rename', () => 'Updated!')
2929

3030
const profile2 = new Elysia()
31-
.onBeforeHandle({ as: 'global' }, ({ status }) => status(401))
32-
.get('/profile', ({ status }) => status(401))
31+
.onBeforeHandle({ as: 'global' }, ({ status }) => status("Unauthorized"))
32+
.get('/profile', ({ status }) => status("Unauthorized"))
3333

3434
const demo2 = new Elysia()
3535
.use(profile2)
3636
// This will NOT have sign in check
37-
.patch('/rename', ({ status }) => status(401))
37+
.patch('/rename', ({ status }) => status("Unauthorized"))
3838
</script>
3939

4040
# Key Concept <Badge type="danger" text="MUST READ" />

docs/patterns/error-handling.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const demo = new Elysia()
2828
})
2929
.get('/throw', ({ error }) => {
3030
// This will be caught by onError
31-
throw error(418) // or error("I'm a teapot")
31+
throw error(418)
3232
})
3333
.get('/return', ({ status }) => {
3434
// This will NOT be caught by onError
35-
return status(418) // or status("I'm a teapot")
35+
return status(418)
3636
})
3737

3838
const demo2 = new Elysia()
@@ -300,11 +300,11 @@ new Elysia()
300300
})
301301
.get('/throw', ({ status }) => {
302302
// This will be caught by onError
303-
throw status(418) // or status("I'm a teapot")
303+
throw status(418)
304304
})
305305
.get('/return', ({ status }) => {
306306
// This will NOT be caught by onError
307-
return status(418) // or status("I'm a teapot")
307+
return status(418)
308308
})
309309
```
310310

0 commit comments

Comments
 (0)