diff --git a/docs/migrate/from-express.md b/docs/migrate/from-express.md index 471d56db..8707bf8e 100644 --- a/docs/migrate/from-express.md +++ b/docs/migrate/from-express.md @@ -521,6 +521,18 @@ const app = new Elysia() While Express has a `next` function to call the next middleware, Elysia does not has one. +::: tip +Unlike Express which only accepts numeric status codes, Elysia also supports descriptive string names: + +```ts +// Both are equivalent in Elysia +return status(401) +return status('Unauthorized') +``` + +String status names provide TypeScript autocompletion for all valid HTTP statuses, making your code more readable and less error-prone. +::: + ## Sounds type safety Elysia is designed to be sounds type safety. diff --git a/docs/migrate/from-fastify.md b/docs/migrate/from-fastify.md index eebc0c28..901c7505 100644 --- a/docs/migrate/from-fastify.md +++ b/docs/migrate/from-fastify.md @@ -549,6 +549,18 @@ const app = new Elysia() +::: tip +Unlike Fastify which only accepts numeric status codes, Elysia also supports descriptive string names: + +```ts +// Both are equivalent in Elysia +return status(401) +return status('Unauthorized') +``` + +String status names provide TypeScript autocompletion for all valid HTTP statuses, making your code more readable and less error-prone. +::: + ## Sounds type safety Elysia is designed to be sounds type safety. diff --git a/docs/migrate/from-hono.md b/docs/migrate/from-hono.md index 60b21e2c..3c3ca602 100644 --- a/docs/migrate/from-hono.md +++ b/docs/migrate/from-hono.md @@ -531,6 +531,18 @@ const app = new Elysia() While Hono has a `next` function to call the next middleware, Elysia does not has one. +::: tip +Unlike Hono which only accepts numeric status codes, Elysia also supports descriptive string names: + +```ts +// Both are equivalent in Elysia +return status(401) +return status('Unauthorized') +``` + +String status names provide TypeScript autocompletion for all valid HTTP statuses, making your code more readable and less error-prone. +::: + ## Sounds type safety Elysia is designed to be sounds type safety. diff --git a/docs/migrate/from-trpc.md b/docs/migrate/from-trpc.md index 26896eba..f4d63476 100644 --- a/docs/migrate/from-trpc.md +++ b/docs/migrate/from-trpc.md @@ -517,6 +517,18 @@ const app = new Elysia() 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. +::: tip +Like tRPC's string error codes (e.g., `"UNAUTHORIZED"`), Elysia supports both numeric and string status names: + +```ts +// Both are equivalent in Elysia +return status(401) +return status('Unauthorized') +``` + +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. +::: + ## Sounds type safety Elysia is designed to be sounds type safety.