Skip to content

This is a containerized Node.js app that provides a RESTful API and stores its data in DynamoDB.

Notifications You must be signed in to change notification settings

joechoi-git/rgc-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rgc-api

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.

Stack

TypeScript, Node.js, Docker, and DynamoDB.

Installation

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 

To deploy

sam build
sam deploy
# open https://v936r8sd70.execute-api.us-west-2.amazonaws.com/Prod/concepts

Available API Endpoints

Retrieve all concepts

curl https://v936r8sd70.execute-api.us-west-2.amazonaws.com/Prod/concepts

Add or update a concept

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",...}'

Delete a concept

curl -X DELETE https://v936r8sd70.execute-api.us-west-2.amazonaws.com/Prod/concepts \
     -H "Content-Type: application/json" \
     -d '{"id":"1"}'

Add a resource to your application

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.

Fetch, tail, and filter Lambda function logs

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.

Unit tests

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

Cleanup

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

Resources

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

About

This is a containerized Node.js app that provides a RESTful API and stores its data in DynamoDB.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published