This repository contains a project for creating a dynamic CRUD (Create, Read, Update, Delete) API using AWS CDK (Cloud Development Kit) with TypeScript. The API is designed to be flexible and scalable, allowing for dynamic handling of various entities.
- bin/: Contains the entry point for the CDK application.
- lib/: Contains the CDK stack definition.
- src/: Contains the Go source code for the Lambda function handling the API requests.
npx cdk deploy- Deploy this stack to your default AWS account/regionnpx cdk diff- Compare deployed stack with current state
The API provides the following endpoints for dynamic CRUD operations:
- GET /: Returns the health status of the API.
-
GET /api/:entity: Retrieve all records of a specified entity.
- Parameters:
entity(path) - The name of the entity to retrieve records for.
- Parameters:
-
GET /api/:entity/:id: Retrieve a single record by ID.
- Parameters:
entity(path) - The name of the entity.id(path) - The ID of the record to retrieve.
- Parameters:
-
POST /api/:entity: Create a new record for a specified entity.
- Parameters:
entity(path) - The name of the entity.
- Body: JSON object representing the new record.
- Parameters:
-
PUT /api/:entity/:id: Update an existing record by ID.
- Parameters:
entity(path) - The name of the entity.id(path) - The ID of the record to update.
- Body: JSON object representing the updated record.
- Parameters:
-
DELETE /api/:entity/:id: Delete a record by ID.
- Parameters:
entity(path) - The name of the entity.id(path) - The ID of the record to delete.
- Parameters:
To set up the local API for development using AWS SAM (Serverless Application Model), follow these steps:
-
Install AWS SAM CLI: Follow the installation guide to install the SAM CLI.
-
Build the SAM Application:
sam build
-
Start the API Locally:
sam local start-api -
Invoke the API: You can now send HTTP requests to the local endpoint, for example
http://localhost:3000/api/<entity-name>.
This project is licensed under the MIT License.