This is a demo project for dynamoically generating a mock API with real data using AWS API Gateway and AWS Lambda. It is a demo for this blog post: http://superluminar.io/2025/04/04/generate-mock-apis-from-real-data-using-nock-and-aws-cdk/.
- Node
- AWS CDK
- AWS Account
The scripts folder contains scripts for generating mock data and preprocessing it for the API.
record-api.ts is a script that records the API calls and saves them to a file.
get-path-response-mapping.ts is a script that reads the recorded API calls and creates a mapping of paths to responses.
The mock-api-demo-stack.ts stack contains the API Gateway which uses MockIntegrations to service the mock responses. This requires the get-path-response-mapping.ts script.
The mock-api-proxy-demo-stack.ts stack contains the API Gateway which uses a proxy with a Lambda function to return the mock responses.
The functions folder contains the Lambda function for the API - proxy-lambda.ts. It is only used in the mock-api-proxy-demo-stack.ts stack.