Request/Response APIs in JavaScript web frameworks

2 points by begoon 2 days ago | 4 comments

Out of curiosity, in web frameworks, what style of passing requests and responses to a handler you prefer: express-js style with non-standard req/res objects or hono/elysia style with standard web Request and Response objects? and why?

benoau a day ago | next |

I like parameter objects a lot these days, they are more verbose to set up initially but they make function calls descriptive and the parameter order irrelevant, I think this is really good for developer usability.

I dislike parameters within the URL now, when you consider the usability of Swagger and browser debug consoles a URL like `/api/update-thing?id=foo` is much nicer for non-developers, whereas `PATCH /api/thing/:id` is built on understanding REST conventions and generates ambiguous requests in browser tools.

throwaway48540 2 days ago | prev | next |

Express-style, because it's very easy to work with my response asynchronously (before returning from my handler function) - e.g. respond with 200 immediately and then process the received data, or stream my response during processing.

shortrounddev2 2 days ago | prev | next |

I would vastly prefer controller endpoints to have actual objects and url params passed in rather than having to deal with a request or response object