TESTE MERCAFACIL

START SERVIDOR

  • Sobe os containers de banco
    docker-compose up --buil -d

  • Cria a tabela de contacts no mysql
    docker exec -i container_mysql mysql -u admin --password=admin admin < ./create-table-macapa.sql

  • Manda o sql para criar a tabela de contacts no postgres
    docker cp ./create-table-varejao.sql container_postgres:/docker-entrypoint-initdb.d/dump.sql

  • Execurta o sql no postgres criando a tabela contacts
    docker exec -u postgres container_postgres psql postgres admin -f docker-entrypoint-initdb.d/dump.sql

  • Roda o backend
    go run main.go

API’s

Login

POST http://localhost:5000/api/v1/login

OBS: login do tipo Bearer

Request

{
	"email":"[email protected]",
	"password":"123456"
}

Responde

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ2YXJlamFvQGdtYWlsLmNvbSIsImV4cCI6MTY0MzkyOTg4OCwiaWF0IjoxNjQzOTIyNjg4LCJpc3MiOiJtZXJjYWZhY2lsIn0.2xRXjq6WVtE4N9FgQN1YtHxxONN59ZF5puSaOWFE4Ek"
}

Contacts

GET http://localhost:5000/api/v1/contacts

Responde

{
  "contacts": [
    {
      "id": 1,
      "name": "EDUARDO",
      "cellphone": "88981301888",
      "email": "[email protected]"
    }
  ]
}

Contacts

POST http://localhost:5000/api/v1/contacts

Request

{
  "contacts": [
		{
			"name":"Eduardo",
			"cellphone":"88981301888"
		}
	]
}

Responde

{
  "contacts": [
    {
      "id": 1,
      "name": "EDUARDO",
      "cellphone": "88981301888",
      "email": "[email protected]"
    }
  ]
}

Contacts

PUT http://localhost:5000/api/v1/contacts

Request

	{
			"name":"jose Eduardo dos Santos",
			"cellphone":"5588981301888"
	}

Responde

{
  "id": 1,
  "name": "jose Eduardo dos Santos",
  "cellphone": "558881301888",
  "email": "[email protected]"
}

Contacts

DELETE http://localhost:5000/api/v1/contacts/1

Responde

"sucess"

GitHub

View Github