To run this app:
- Rename
.env.example
to.env
, and update the values accordingly. - Run
docker-compose up --build
. - If redis' data is not yet initialized, go inside the node app container and run
npm run seeder
or simply rundocker-compose run node npm run seeder
.
To stop this app:
Run this command: docker-compose down
In order to access the endpoints below, every request should contain a basic authentication with the username and password saved in redis.
Username and password can be set on .env
and be saved to redis when npm run seeder
is run.
Get list of countries.
Query Params:
- sort_by - Country field to be compared for sorting. Possible values are
name
,code
andpopulation
. - order_by - Result order. Possible values are
asc
, anddesc
. Default value isasc
if this param is not provided.
Response:
{
"message": "Here are the countries.",
"data": [
{
"name": "AFGHANISTAN",
"code": "afg",
"population": 0
},
{
"name": "ALBANIA",
"code": "alb",
"population": 0
}
]
}
Update a country's data. Provide the country fields to be updated in the request body.
Body:
{
"population": 100
}
Response:
{
"message": "Country is updated."
}
Delete a country.
Response:
{
"message": "Country is updated."
}