How do I access the event and context from a NestJs controller?
Closed this issue · 1 comments
rsegecin commented
The event and context are already accessible in index.ts but how to access them from an HTTP method in AppController?
This issue #4 event and context seem to be accessed using the usual nodejs express method.
I intended to access the event like is shown below but maybe through the Request itself if it had "req.apiGateway".
@Post("email")
async registerEmail(@Req() req: Request, @Body() email: RegisterEmailDTO, event: APIGatewayProxyEvent): Promise<string> {
const ipaddress = event.requestContext.identity.sourceIp;
console.log("ipaddress: " + ipaddress, email);
const r = await this.registerService.registerEmail(email.email, ipaddress);
return r;
}