fixture reservations, one HTTP call away ⚽
tools | remarks |
---|---|
Docker | required |
nvm | for managing your Node JS environment |
Redis (optional) | if you prefer running a Redis instance on host machine; else see docker-compose file |
First, make sure you are using the right Node JS environment.
nvm install # should install the version specified in .nvmrc
nvm use
Then, simply install, and grab a cup of coffee while at it ☕.
npm install # including dev dependencies
We provided sample env files in the names of env-*.yml.sample
. You can copy these sample files, removing the .sample
extension.
Please modify the environment variables accordingly.
Because we require AWS API Gateway and Lambda functions (with Serverless Framework), we can simply use the Serverless Offline tool to simulate a 'local' API Gateway to invoke our Lambda functions via HTTP interface.
# NOTE: local server will be listening on port 7001
sls offline --printOutput
# runs both Redis container and Swagger UI for API testing;
# Else, run the services individually if preferred
docker-compose up
# using o'fashioned curl to create a fixture request
curl -H 'Authorization: Basic [username:password encoded in base64]'\
-H 'Content-Type: application/json'\
-X POST\
-d '{"court": "outdoor", "date": "2020-12-31", "time": "1700-1900"}'\
http://localhost:7001/bonfim\
| jq ".id"
# (optional) you can also pipe the response to jq and get the id
If a graphical UI is preferred instead, check out how to test using Swagger UI
We use Eslint for linting, and follow the now-classic Airbnb Eslint config.
npm run lint
npm test
Please see here for the API document (following OpenAPI 3.0).
For a more interactive experience with Swagger UI, you may like to:
docker-compose up openapi
and point to http://localhost:7777