Skip to content

IsaacMurtagh/PartyGames_Server

Repository files navigation

partygames-app

Deploy the sample application

Deploying to dev

sam build && sam deploy samconfig.toml

deploying to production

sam build && sam deploy samconfig.toml --config-env prod

You can find your API Gateway Endpoint URL in the output values displayed after deployment.

Testing Locally

first run docker-compose up to run dynamoDb

docker-compose up

then run ./init.sh to create all required tables

./init.sh

Then run functions locally and invoke them with the sam local invoke command.

sam build && sam local invoke GameFunction --event events/games/postGame.json --docker-network lambda-local

The SAM CLI can also emulate your application's API. Use the sam local start-api to run the API locally on port 3000.

sam build && sam local start-api --docker-network lambda-local
curl http://localhost:3000/health

The --docker-network command allows the sam api and lambda to talk to docker as they're hosted in separate containers. Inside the docker-compose.yaml file, lambda-local is specified as the network for the DB

The SAM CLI reads the application template to determine the API's routes and the functions that they invoke.

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.

sam logs -n GameFunction --stack-name partygames-app --tail

You can find more information and examples about filtering Lambda function logs in the SAM CLI Documentation.

Unit tests

Use NPM to install the Mocha test framework and run unit tests.

cd src/game
npm install
npm run test

Resources

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

Basic project structure

.
├── README.md
├── docker-compose.yml
├── docs
│   └── games.md
├── events
│   └── games
│       └── postGame.json
├── init.sh
├── samconfig.toml               <--- Configs for cli deployment
├── src
│   └── game                     <--- Deployed to Lambda
│       ├── app.js
│       ├── dbClient.js
│       ├── gamesTable.js
│       ├── handlers
│       │   ├── createGame.js
│       │   └── getGame.js
│       ├── models
│       │   └── Game.js
│       ├── package.json
│       └── tests
│           └── unit
└── template.yaml                <--- Cloud formation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published