vandium-io/vandium-node

Support for multiple HTTPMethod handler for different routes in the same AWS Lambda handler

skewl84 opened this issue · 2 comments

Firstly, thanks for this project. This is really helpful in stubbing up the handler for the API gateway.

I'm fairly new to the vandium and I was wondering how does one enable multiple handlers for routes

e.g.
GET /users
GET /user/1

Is it possible to do this via a single aws lambda handler or would I need to create separate handlers

Thanks in advance

You could, but it's not the most optimal from a security, testing and architecture perspective. I would suggest having each operation in a separate handler, use a layer to consolidate common logic and apply the least permissive access constraints. Testing a single operation will be a lot easier, and long term technical debt will be lower.

For my own projects, I am using AWS CDK rather than SAM or serverless, as it lets me deploy my application via code rather than configuration files.

Thanks @richardhyatt for the insights, much appreciated.

It's just that the api-gateway example in the docs show the GET, POST in a single handler due to which I presumed that is recommended way of implementing the handlers via vandium.

I understand and totally agree with the approach of separating the handlers for each operation and did feel like the obvious way of doing so.

Thanks again.