middyjs / middy

🛵 The stylish Node.js middleware engine for AWS Lambda 🛵
https://middy.js.org
MIT License
3.73k stars 376 forks source link

HTTP Router Proposal #596

Closed willfarrell closed 2 years ago

willfarrell commented 3 years ago

Proposal for a new http router middleware that could allow for multiple api endpoints to be resolved by the same lambda. This can be beneficial for endpoints that are likely to hit cold starts and other strategies.

Related work: https://www.npmjs.com/package/middy-reroute

Please 👍🏻 this issue if it would have value to you.

If you can comment with your use case below, that would be helpful.

nponeccop commented 3 years ago

I don't need an HTTP router, but I could benefit from an arbitrary router. That is, you form an arbitrary routing key and then route based on the key, or something like that. In my app, a user has routeId stored in the database. When it calls my API, I get routeId from his userId and call different backends depending on that. I'm not sure if it such a router is useful to enough people though.

willfarrell commented 2 years ago

I've put together a http-router (https://github.com/middyjs/middy/pull/782). Still needs a little love, but think it's mostly there. Would like some feedback on features people were hoping it would have.

Sorry, but it's not a generic router. You could lift the logic and build your own with ease.