-
Notifications
You must be signed in to change notification settings - Fork 1
Description
For Lambda based setup the req object is not needed at all.
For node.js server based public access to req object is not 100% needed. I should be private and access to its functionality can be abstracted by Context object. getHeaders(), header(name), getReadStream(), and we already have originalUri, etc.
The downside is that req object cannot be injected anymore. But that's good because if Req is injected into any controller then it will not be able to run in Lambda setup because we don't want to setup Req object for Lambda - it's alot of extra work.
What can be done is have a getter for Req object and then return req if it exists and in Lambda based Context class can override it to create Req object on the fly if requested.
Eliminating access to Response object is good thing because if any middleware or controller uses injected @response and writes to response then it will not work in Lambda based environment.
How can bind-rest-aws-lambda augment the Context class? We pass Context class to initialization function so we can augment it's prototype after it is created with .create() or even before it is created because we are passing actual prototype.
can add new class for contextStorage that will hold Lambda event, context or can add new property awsLambda that will hold event, context. Can augment getRequest() method that will generate req on the fly.