henriquebarrosx / CoinConverterApi

πŸ’° Uma API em TypeScript desenvolida com Express para converção de moedas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Currency Converter

API for converting between BRL, USD, EUR, JPY currencies.


βš’οΈ Resources


πŸƒβ€β™‚οΈ Running

Setup

  1. Setup a postgres database url in .env file DATABASE_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

  1. Run the project: npm run dev

  2. Try to use the currency conversion doc


πŸ€ Features

  • 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'

βœ”οΈ Desired items

[βœ”οΈ] - Logs [βœ”οΈ] - Exception handler [βœ”οΈ] - Documentation [βœ”οΈ] - Clear commits message [βœ”οΈ] - Lint config [βœ”οΈ] - Unit test [βœ”οΈ] - Integration test [βœ”οΈ] - Endpoints documentation [❌] - Deploy [❌] - CI/CD


πŸ“¦ Folder structure

πŸ“¦ 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


🎯 Tools Motivation

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.


πŸ‘¦ Developer


Henrique Barros

About

πŸ’° Uma API em TypeScript desenvolida com Express para converção de moedas

License:MIT License


Languages

Language:TypeScript 97.7%Language:JavaScript 2.3%