Running Lambda application logic locally
You might have noticed that since we changed the infrastructure code to serverless, we haven’t touched the server’s folder code. You might be wondering if we are still going to use it. The answer is yes: we are going to use it for local development in the same way we were using it when we had RDS, but we will have to make some changes to make it work with DynamoDB. Additionally, we will import the same code that is running inside the deployed Lambda function into the local server and run it in their POST
and GET
routes. So, let’s get started.
You can find all the code discussed here in the server/src/index.ts
file.
The first thing we need to do is import the code used in the Lambda integration of API Gateway for POST
and GET
endpoints:
import { handler as PostHandler } from '../../infrastructure/lib/constructs/Lambda/post/lambda'; import { handler as GetHandler } from '../../infrastructure/lib/constructs...