Skip to content

Commit db55479

Browse files
committed
docs: use string status names consistently across remaining files
Convert remaining numeric status codes to descriptive strings: - status(401) → status("Unauthorized") in auth contexts - status(400) → status("Bad Request") or status("Unauthorized") as appropriate Files updated: - docs/index.md (homepage examples) - docs/integrations/better-auth.md - docs/tutorial/patterns/extends-context/index.md - docs/patterns/extends-context.md - docs/eden/treaty/response.md
1 parent 5e5da8b commit db55479

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

docs/eden/treaty/response.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { treaty } from '@elysiajs/eden'
3030

3131
const app = new Elysia()
3232
.post('/user', ({ body: { name }, status }) => {
33-
if(name === 'Otto') return status(400)
33+
if(name === 'Otto') return status("Bad Request")
3434

3535
return name
3636
}, {
@@ -146,7 +146,7 @@ import { treaty, Treaty } from '@elysiajs/eden'
146146

147147
const app = new Elysia()
148148
.post('/user', ({ body: { name }, status }) => {
149-
if(name === 'Otto') return status(400)
149+
if(name === 'Otto') return status("Bad Request")
150150

151151
return name
152152
}, {

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const role = new Elysia({ name: 'macro' })
112112
role: (type: 'user' | 'staff' | 'admin') => ({
113113
beforeHandle({ headers, status }) {
114114
if(headers.authorization !== type)
115-
return status(401)
115+
return status("Unauthorized")
116116
}
117117
})
118118
})
@@ -159,7 +159,7 @@ export const auth = new Elysia()
159159
ssid: t.String()
160160
}),
161161
resolve({ cookie, status }) {
162-
if(!cookie.ssid.value) return status(401)
162+
if(!cookie.ssid.value) return status("Unauthorized")
163163

164164
return {
165165
user: cookie.ssid.value
@@ -189,7 +189,7 @@ export const auth = new Elysia()
189189
ssid: t.String()
190190
}),
191191
resolve({ cookie, status }) {
192-
if(!cookie.ssid.value) return status(401)
192+
if(!cookie.ssid.value) return status("Unauthorized")
193193

194194
return {
195195
user: cookie.ssid.value

docs/integrations/better-auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const betterAuth = new Elysia({ name: 'better-auth' })
189189
headers
190190
})
191191

192-
if (!session) return status(401)
192+
if (!session) return status("Unauthorized")
193193

194194
return {
195195
user: session.user,

docs/patterns/extends-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ new Elysia()
317317
.derive(({ headers, status }) => {
318318
const auth = headers['authorization']
319319

320-
if(!auth) return status(400)
320+
if(!auth) return status("Unauthorized")
321321

322322
return {
323323
bearer: auth?.startsWith('Bearer ') ? auth.slice(7) : null

docs/tutorial/patterns/extends-context/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ new Elysia()
161161
)
162162
})
163163
.resolve(({ query: { age }, status }) => {
164-
if(!age) return status(401)
164+
if(!age) return status("Unauthorized")
165165

166166
return { age }
167167
})

0 commit comments

Comments
 (0)