Skip to content

Commit

Permalink
Refactor getGuestsHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
ProchaLu committed Aug 2, 2024
1 parent d59bc5e commit 6ba4664
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,27 @@ app.get(
},
);

type ResponseBody = Guest[] | Guest | { errors: { message: string }[] };

// Get all guests
app.get(
'/guests',
function getGuestsHandler(request: Request, response: Response<Guest[]>) {
function getGuestsHandler(
request: Request,
response: Response<ResponseBody>,
) {
response.json(guestList);
},
);

type RequestBodyPost = {
body: { firstName: string; lastName: string; deadline?: string };
body: {
firstName: string;
lastName: string;
deadline?: string;
};
};

type ResponseBody = Guest | { errors: { message: string }[] };

// New guest
app.post(
'/guests',
Expand Down

0 comments on commit 6ba4664

Please sign in to comment.