https://github.com/jmb12686/aws-dynamo-microservice
https://github.com/jmb12686/aws-dynamo-microservice
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jmb12686/aws-dynamo-microservice
- Owner: jmb12686
- Created: 2020-07-27T20:05:43.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T12:47:22.000Z (almost 3 years ago)
- Last Synced: 2025-04-02T11:23:22.283Z (6 months ago)
- Language: TypeScript
- Size: 1.03 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# aws-dynamo-microservice
This is a simple demo microservice API utilizing AWS Lambda, API Gateway, and DynamoDB provisioned via AWS CDK. The application exposes a RESTful CRUD API backed by a DynamoDB table.
## Build
To build this application run the following:
```bash
npm install -g aws-cdk
npm install
npm run build
```## Deploy
To deploy this application, use `cdk` and run the following commands:
```bash
cdk bootstrap; #only have to run once, no-op if ran again
cdk deploy
```After CDK completes the deployment, the API's URL will be printed as output
## Lambda application code
The Lambda application code is under `app/src` and contains:
* `app/src/createOrder` - used to store an order in the DynamoDB table
* `app/src/getOneOrder` - used to get a single order from the DynamoDB table
* `app/src/getAllOrders` - used to get all orders from the DynamoDB table## API
### Create an order
HTTP POST to `{OrdersAPIEndpoint}/orders` with `customerId` and `orderId` elements in the body as JSON. Example:
```bash
curl -X POST -d '{"customerId":"JoeUser1234", "orderId":"3", "amount":"12"}' https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders
```### Get a single order
HTTP GET to `{OrdersAPIEndpoint}/orders/{customerId}/{orderId}` Example:
```bash
curl -X GET https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders/JoeUser1234/3
```### Get all orders
HTTP GET to `{OrdersAPIEndpoint}/orders` Example:
```bash
curl -X GET https://XXXXXXXXX.execute-api.us-east-1.amazonaws.com/prod/orders/
```