Use lambda_create.sh to create lambda function in AWS console. It takes a single parameter which can be one of:
- CreateMatch
- CreatePlayer
- GetMatches
- getPlayers
Remember to update environment variables in AWS console afterwards.
Use lambda_update.sh after each change in lambda code.
Use lambda_invoke.sh to perform a live test. Check lambdas description below for more details.
Creates a match, with corresponding scores
# Example
./lambda_invoke.sh CreateMatch "{\"scores\":[{\"player_ids\":[1,2],\"score\":1},{\"player_ids\":[4,6],\"score\":3}]}"
# Response
"{\"id\":22,\"scores\":[{\"id\":42,\"players\":[{\"id\":1,\"name\":\"\"},{\"id\":2,\"name\":\"\"}],\"score\":1},{\"id\":43,\"players\":[{\"id\":4,\"name\":\"\"},{\"id\":6,\"name\":\"\"}],\"score\":3}]}"
Creates a player
Parameters:
- name
# Example (do not use lambda_invoke.sh when passing parameters with spaces)
./lambda_invoke.sh CreatePlayer "{\"name\":\"Samuel\"}"
# Response
"{\"id\":17,\"name\":\"Samuel\"}"
Lists all players
# Example
./lambda_invoke.sh GetPlayers
# Response
"[{\"id\":3,\"name\":\"A\"},{\"id\":4,\"name\":\"B\"},{\"id\":5,\"name\":\"C\"},{\"id\":6,\"name\":\"D\"},{\"id\":7,\"name\":\"E\"},{\"id\":8,\"name\":\"F\"},{\"id\":9,\"name\":\"G\"},{\"id\":10,\"name\":\"H\"},{\"id\":1,\"name\":\"Z\"},{\"id\":2,\"name\":\"X\"},{\"id\":11,\"name\":\"Y\"},{\"id\":12,\"name\":\"Sam Wise\"}]"
Lists matches
Parameters:
- per_page [10|25|50], default = 10
- page, default = 1
# Example
./lambda_invoke.sh GetMatches "{\"per_page\":10,\"page\":1}"
# Response
"[{\"id\":13,\"scores\":[{\"id\":24,\"players\":[{\"id\":1,\"name\":\"Z\"},{\"id\":2,\"name\":\"X\"}],\"score\":1},{\"id\":25,\"players\":[{\"id\":4,\"name\":\"B\"},{\"id\":6,\"name\":\"D\"}],\"score\":3}]},{\"id\":14,\"scores\":[{\"id\":26,\"players\":[{\"id\":1,\"name\":\"Z\"},{\"id\":2,\"name\":\"X\"}],\"score\":1},{\"id\":27,\"players\":[{\"id\":4,\"name\":\"B\"},{\"id\":6,\"name\":\"D\"}],\"score\":3}]}]"
You may populate database with dump file in sql folder.
Copy .env.sample file to .env and update configuration parameters.
Each lambda may be tested by opening its folder (ie. cd GetPlayers
) and running go test
.