Git Product home page Git Product logo

transactions's Introduction

Intro

The code was designed to have clear responsibilities and to be easy to test and mock. I developed it guided to interfaces.

Test Coverage

test-coverage

Folder Structure

api/services

Here is the brain, the core use cases is written here. Files here will be responsible for use cases like: Create a Transaction and an Account

api/controllers

Where I store the transactionsController and accountsController. Their responsibility is to get a request, call a service and return a response to the client.

api/models

A model is a structure that shapes the data. It defines the column attributes and it is used for migrations. I don't store any business logic here

api/repositories

Here I'm storing some structs that will make the queries in the DB. Create, Update, Delete and Find queries are wrapped inside it. This way my service doesn't need to know which adapter is being used (postgres, mysql, mongo, etc...)

API Doc

POST /accounts

  • Create Valid account valid-account

  • Invalid Account (non-numeric document number) invalid-account

  • Invalid Account (empty document number) empty-docNumber-invalid-account

GET /accounts/:id

  • Existent account found-account

  • Non existent account invalid-account

POST /transactions

  • Valid transactions valid-transaction

    valid-negative-transaction

  • Invalid transactions invalid-negative-transaction

    invalid-positive-transaction

    invalid-operation-type

How to run

$ git pull https://github.com/emmanuelperotto/transactions.git
$ cd pismo-test
$ docker-compose up --build

How to run the tests

$ go test -coverprofile=coverage.out -v ./...
$ go tool cover -html=coverage.out

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.