@@ -271,16 +271,16 @@ const app = createApp().get(
271271When defining multiple schemas for different status codes, instead of returning the value directly, you'll need to return the value of the ` status ` function:
272272
273273``` ts
274- import { ErrorResponse , createApp , Status } from " @aklinker1/zeta" ;
275- import { NotFoundError } from " @aklinker1/zeta/errors" ;
274+ import { ErrorResponse , createApp , HttpStatus } from " @aklinker1/zeta" ;
275+ import { NotFoundHttpError } from " @aklinker1/zeta/errors" ;
276276
277277const app = createApp ().post (
278278 " /api/users" ,
279279 {
280280 body: UserSchema ,
281281 responses: {
282- [Status .Created ]: User ,
283- [Status .Conflict ]: ErrorResponse ,
282+ [HttpStatus .Created ]: User ,
283+ [HttpStatus .Conflict ]: ErrorResponse ,
284284 },
285285 },
286286 async ({ status , body }) => {
@@ -290,14 +290,14 @@ const app = createApp().post(
290290 // Zeta maps the HttpError's status code to the correct response schema.
291291 if (userExists ) {
292292 throw new HttpError (
293- Status .Conflict ,
293+ HttpStatus .Conflict ,
294294 " A user with this email already exists." ,
295295 );
296296 }
297297
298298 const newUser = await db .createUser (body );
299299
300- return status (Status .Created , newUser );
300+ return status (HttpStatus .Created , newUser );
301301 },
302302);
303303```
@@ -393,7 +393,7 @@ Here's an example combining several different hooks:
393393
394394``` ts
395395import { createApp } from " @aklinker1/zeta" ;
396- import { NotFoundError } from " @aklinker1/zeta/errors" ;
396+ import { NotFoundHttpError } from " @aklinker1/zeta/errors" ;
397397
398398const usersApp = createApp ({ prefix: " /api/users" })
399399 .get (" /" , {}, () => {
@@ -409,7 +409,7 @@ const usersApp = createApp({ prefix: "/api/users" })
409409 })
410410 .onBeforeHandle (async ({ path }) => {
411411 const user = await getUser (path .userId );
412- if (user == null ) throw new NotFoundError (" User not found" );
412+ if (user == null ) throw new NotFoundHttpError (" User not found" );
413413
414414 return { user };
415415 })
@@ -619,10 +619,10 @@ By default, Zeta provides built-in error handling. It also provides useful error
619619
620620``` ts
621621import { HttpError } from " @aklinker1/zeta/errors" ;
622- import { Status } from " @aklinker1/zeta/status" ;
622+ import { HttpStatus } from " @aklinker1/zeta/status" ;
623623
624624const app = createApp ().get (" /users" , {}, () => {
625- throw new HttpError (Status .NotImplemented , " TODO" );
625+ throw new HttpError (HttpStatus .NotImplemented , " TODO" );
626626});
627627```
628628
@@ -657,12 +657,12 @@ const app = createApp()
657657
658658When a non-` HttpError ` value is thrown, Zeta returns a ` 500 Internal Server Error ` with the original error as the ` cause ` .
659659
660- ## Status Codes
660+ ## HttpStatus Codes
661661
662662Zeta provides an enum of all HTTP status codes. You should use this instead of literal values.
663663
664664``` diff
665- import { Status } from "@aklinker1/zeta/status";
665+ import { HttpStatus } from "@aklinker1/zeta/status";
666666
667667const app = createApp()
668668 .post(
@@ -671,7 +671,7 @@ const app = createApp()
671671 ({ set }) => {
672672 // ...
673673- set.status = 201;
674- + set.status = Status .Created;
674+ + set.status = HttpStatus .Created;
675675 },
676676 );
677677```
@@ -746,7 +746,7 @@ expect(response).toEqual([...]);
746746await expect (
747747 () => client .fetch (" GET" , " /users/123" , {})
748748).rejects .toEqual ({
749- status: Status .NotFound ,
749+ status: HttpStatus .NotFound ,
750750 message: " User not found" ,
751751})
752752```
0 commit comments