API for converting between BRL, USD, EUR, JPY currencies.
- Tools
- Consumed API
- Setup a postgres database url in
.env
fileDATABASE_URL
, exemple:
API_KEY=123456990120310912031 # Visit https://apilayer.com and put your API key here
DATABASE_URL="mongodb+srv://<USER>:<PASSWORD>@<HOST>/currencyconverterdb"
OBS: Prisma setup use mongodb provider. So, should be defined a valid mongodb database URL
-
Run the project:
npm run dev
- Create transactions to convert currencies
# /api/v1/transactions
curl -X POST http://localhost:3333/api/v1/transactions \
-H 'Content-Type: application/json' \
-d '{ "from": "BRL", "to": "USD", "amount": 5 }'
- List registered transactions
# /api/v1/transactions
curl -X GET http://localhost:3333/api/v1/transactions \
-H 'Content-Type: application/json'
[βοΈ] - Logs [βοΈ] - Exception handler [βοΈ] - Documentation [βοΈ] - Clear commits message [βοΈ] - Lint config [βοΈ] - Unit test [βοΈ] - Integration test [βοΈ] - Endpoints documentation [β] - Deploy [β] - CI/CD
π¦ currency-converter
β£ π prisma
β£ π src
β β£ π common-types
β β£ π exception
β β£ π providers
β β β β£ π database
β β β β£ π http-client
β β β β£ π logger
β β£ π v1
β β β£ π entities
β β β£ π middlewares
β β β£ π repositories
β β β£ π use-cases
β β β β£ π create-transaction
β β β β£ π list-transaction
β β£ π routes
β β£ π index.ts
β£ π .gitignore
β£ π README.md
β£ π LICENSE
β£ π package-lock.json
β£ π package.json
β£ π tsconfig.json
Thinking about a simple project, easy to test and with high capacity to improvements, the API was built using the clean architecture principles. It came up with pros and cons, like tools limitation that could work togheter respecting these principles. Prisma and axios are one of those! Prisma combined the ability to work with repositories without dirt things in our entities and low accoplament, for example. Axios, on the other hand, provided a way to handle with http client to handle with requests.
Henrique Barros