Skip to content

Commit b9f5ef7

Browse files
committed
docs(migrate): highlight Elysia string status name advantage
Adds tip boxes to all migration guides highlighting that Elysia supports both numeric and string status names, unlike Express/Fastify/Hono which only accept numeric codes. This is a genuine DX advantage worth showcasing to users migrating from other frameworks.
1 parent 5e5da8b commit b9f5ef7

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

docs/migrate/from-express.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,18 @@ const app = new Elysia()
521521

522522
While Express has a `next` function to call the next middleware, Elysia does not has one.
523523

524+
::: tip
525+
Unlike Express which only accepts numeric status codes, Elysia also supports descriptive string names:
526+
527+
```ts
528+
// Both are equivalent in Elysia
529+
return status(401)
530+
return status("Unauthorized")
531+
```
532+
533+
String status names provide TypeScript autocompletion for all valid HTTP statuses, making your code more readable and less error-prone.
534+
:::
535+
524536
## Sounds type safety
525537
Elysia is designed to be sounds type safety.
526538

docs/migrate/from-fastify.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,18 @@ const app = new Elysia()
549549

550550
</Compare>
551551

552+
::: tip
553+
Unlike Fastify which only accepts numeric status codes, Elysia also supports descriptive string names:
554+
555+
```ts
556+
// Both are equivalent in Elysia
557+
return status(401)
558+
return status("Unauthorized")
559+
```
560+
561+
String status names provide TypeScript autocompletion for all valid HTTP statuses, making your code more readable and less error-prone.
562+
:::
563+
552564
## Sounds type safety
553565
Elysia is designed to be sounds type safety.
554566

docs/migrate/from-hono.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,18 @@ const app = new Elysia()
531531

532532
While Hono has a `next` function to call the next middleware, Elysia does not has one.
533533

534+
::: tip
535+
Unlike Hono which only accepts numeric status codes, Elysia also supports descriptive string names:
536+
537+
```ts
538+
// Both are equivalent in Elysia
539+
return status(401)
540+
return status("Unauthorized")
541+
```
542+
543+
String status names provide TypeScript autocompletion for all valid HTTP statuses, making your code more readable and less error-prone.
544+
:::
545+
534546
## Sounds type safety
535547
Elysia is designed to be sounds type safety.
536548

docs/migrate/from-trpc.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,18 @@ const app = new Elysia()
517517

518518
While tRPC has a `next` function to call the next middleware in the queue, Elysia use specific event interceptor for each point in the request pipeline.
519519

520+
::: tip
521+
Like tRPC's string error codes (e.g., `"UNAUTHORIZED"`), Elysia supports both numeric and string status names:
522+
523+
```ts
524+
// Both are equivalent in Elysia
525+
return status(401)
526+
return status("Unauthorized")
527+
```
528+
529+
This gives you the readability of tRPC's string codes while staying compliant with HTTP standards. String status names also provide TypeScript autocompletion for all valid HTTP statuses.
530+
:::
531+
520532
## Sounds type safety
521533
Elysia is designed to be sounds type safety.
522534

0 commit comments

Comments
 (0)