This is a basic example of a TS api using third party api, in this case, I'm using Amdoren Currency Api, but the main point of this is including the services of Redis to caching data, and respond to clients faster. So, in the first request we take x time to make a request (usually one second or more), and the second time we take less than 100ms to retrieve the info to the user.
- Swagger
- This project has implemented Swagger Docs, so if you navigate to "http://localhost:5500/docs/#" after starting the project, you can test the endpoints.
- Jest
- Also, this project has implemented jest unit testing, and I have made the testing functions for the main controller of the app (CurrencyController).
- Good practices
- The CurrencyController uses dependency injection, so it was easier to make the testing functions. It receives two arguments, provider service and caching service both based on interfaces, so, if we want to change the strategy we just have to create another class implementing those interfaces.
- Docker
- This app uses docker power, so if you want to run it on your machine just navigate to the root of the project, add a .env file (you have the .env.example, so you just have to add the missing values), and run docker compose up
Note
You will have to create an account on https://www.amdoren.com/currency-api/ to get the api_key
Note
You must have Docker installed and running on your machine
- Clone the project
- Install dependencies with npm install
- Add the api key (token) in the .env file
- Run docker compose up -d
You can see docs here! (/api/currency/getCurrency) www.monkeydeveloper.com/docs