Version Number: 5b8d0fd276b6d288905ed2f63a934e057e8feca2
- Node v14.17.2 (npm v6.14.13)
- Yarn v1.22.13
This repository uses yarn as the package manager, if you do not have yarn globally installed install it with the command below.
npm install -g yarn
yarn install
yarn run buildyarn run test
yarn run buildyarn run server
The server should now be running at port: 3000, should you require a different port please pass a PORT environment.
PORT=8080 yarn run server
You can get a currency converted with a get request providing the correct query parameters.
All responses are in JSON.
Request:
curl --location --request GET 'http://localhost:3000/rate?fromCurrency=EUR'
Response:
{
"data": {
"rate": 1.1387576154415533
}
}
Request:
curl --location --request GET 'http://localhost:3000/convert?fromCurrency=USD&toCurrency=GBP&value=50'
Response:
{
"data": {
"value": 39.28,
"currency": "GBP"
}
}
Request:
curl --location --request GET 'http://localhost:3000/convert?fromCurrency=EUR&toCurrency=GBP&value=50'
Response:
{
"data": {
"value": 44.74,
"currency": "GBP"
}
}
If you fail to provide the required fields, or they are invalid, then you will recieve an error with status code 400.
All responses are in JSON
You can perform an addition using a post request:
Request:
curl --location --request POST 'localhost:3000/convert/addition' \
--header 'Content-Type: application/json' \
--data-raw '{
"toCurrency": "CAD",
"values": [
{
"currency": "EUR",
"value": 13.12
},
{
"currency": "GBP",
"value": 99
}
]
}'
Response:
{
"data": {
"currency": "CAD",
"value": 185.64
}
}