Simple currency exchange app between 'USD' and 'UAH'. App uses 'bank.gov.ua' API to get current day currency rates. Then save it to redis and use cached rate.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
node.js v8 or higher, redis
Download project
git clone 'https://github.com/ShellyShelly/currency-exchange.git'
Open project directory
cd currency-exchange-clone
Download all dependencies
npm install
Copy example.env, rename to development.env and setup all settings(REDIS_PORT, REDIS_URL and server PORT).
example.env file:
PORT=8080
REDIS_PORT=6379
REDIS_URL='127.0.0.1'
Start redis on setted REDIS_PORT.
redis-server --port 6380
Run server in development mode on port 8080
npm run start:dev
Run e2e tests
npm run test:e2e
Run unit tests
npm run test
Get unit test coverage
npm run coverage
Get e2e test coverage
npm run coverage:e2e
Check coding style guide setted in .eslintrc file
npm run lint
// TODO: Add additional notes about how to deploy this on a live system
POST /exchange/
{
"value": number,
"currencyTo": string_currency_3_char_code,
"currencyFrom": string_currency_3_char_code,
}
Field 'value' should be not negative(float or integer).
Fields 'currencyFrom' and 'currencyTo' should be string alike 'USD' or 'UAH'(case insensitive).
Field 'currencyFrom' is optional.
Example 1:
{
"value": 100,
"currencyTo": "UAH",
"currencyFrom": "USD"
}
Change 100 'USD' to 'UAH'
Example 2:
{
"value": 100.0,
"currencyTo": "uAh",
}
Change 100.0 'USD' to 'UAH'
Example response:
{
"result": 2682.7083
}
- Express.js - The web framework used
- Node.js - The JavaScript runtime
- Redis - In-memory data structure store(for caching)
- JOI - Object schema validation
- Dotenv - Module that loads environment variables
- Bluebird - Third party promise library
- Axios - Promise based HTTP client
- Jest - JavaScript Testing Framework
- Supertest - Library made specifically for testing nodejs http servers,