This project was bootstrapped with AWS Serverless Application Model Command Line Interface (AWS SAM CLI). This is a containerized Node.js app that provides a RESTful API and stores its data in DynamoDB.
TypeScript, Node.js, Docker, and DynamoDB.
git clone https://github.com/joechoi-git/rgc-api
cd rgc-api/app
app$: npm install
app$: cd ..
rgc-api$: sam build
rgc-api$: sam local start-api
# open http://localhost:3000/concepts
sam build
sam deploy
# open https://v936r8sd70.execute-api.us-west-2.amazonaws.com/Prod/concepts
curl https://v936r8sd70.execute-api.us-west-2.amazonaws.com/Prod/concepts
curl -X POST https://v936r8sd70.execute-api.us-west-2.amazonaws.com/Prod/concepts \
-H "Content-Type: application/json" \
-d '{"id":"1", "displayName":"Some name",...}'
curl -X DELETE https://v936r8sd70.execute-api.us-west-2.amazonaws.com/Prod/concepts \
-H "Content-Type: application/json" \
-d '{"id":"1"}'
The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in the SAM specification, you can use standard AWS CloudFormation resource types.
To simplify troubleshooting, SAM CLI has a command called sam logs
. sam logs
lets you fetch logs generated by your deployed Lambda function from the command line. In addition to printing the logs on the terminal, this command has several nifty features to help you quickly find the bug.
NOTE
: This command works for all AWS Lambda functions; not just the ones you deploy using SAM.
rgc-api$ sam logs -n FunctionName --stack-name rgc-api --tail
You can find more information and examples about filtering Lambda function logs in the SAM CLI Documentation.
Tests are defined in the app/tests
folder in this project. Use NPM to install the Jest test framework and run unit tests.
rgc-api$ cd app
app$ npm install
app$ npm run test
To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:
sam delete --stack-name rgc-api
See the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.
Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: AWS Serverless Application Repository main page