/gazin-back

Backend para o teste feito para a Gazin

Primary LanguageTypeScript

Migrations:

Para rodar, precisará rodar as migrations antes, para rodar use o comando:

npx ts-node ./node_modules/.bin/typeorm migration:run

Obs: É necessário que o banco de dados já exista com o nome que está na ormconfig.json.

Rotas:

GET /api/developers

QueryString

limit: Número, limita quantos dados serão mostrados.
page: Número, qual página você quer buscar.
keyword: string, para buscar alguém pelo campo nome, que seja parecido.

Response

Status: 200
[
  {
    "id": 1,
    "name": "Tester",
    "gender": "M",
    "age": 27,
    "hobby": "Testar",
    "birthday": "1993-06-28T03:00:00.000Z",
    "created_at": "2021-02-09T02:54:35.429Z",
    "updated_at": "2021-02-09T03:25:01.709Z"
  }
]

QueryString Response

Status: 200
{
  "data": [
    {
      "id": 1,
      "name": "Tester",
      "gender": "M",
      "age": 27,
      "hobby": "Testar",
      "birthday": "1993-06-28T03:00:00.000Z",
      "created_at": "2021-02-09T02:54:35.429Z",
      "updated_at": "2021-02-09T03:25:01.709Z"
    }
  ],
  "count": 1
}

GET /api/developers/:id

Status: 200
[
  {
    "id": 1,
    "name": "Tester",
    "gender": "M",
    "age": 27,
    "hobby": "Testar",
    "birthday": "1993-06-28T03:00:00.000Z",
    "created_at": "2021-02-09T02:54:35.429Z",
    "updated_at": "2021-02-09T03:25:01.709Z"
  }
]

POST /api/developers

Request

{
	"name": "Tester",
	"gender": "M",
	"age": 27,
	"hobby": "Testar",
	"birthday": "06/28/1993"
}

Response

Status: 201
{
    "id": 1,
    "name": "Tester",
    "gender": "M",
    "age": 27,
    "hobby": "Testar",
    "birthday": "1993-06-28T03:00:00.000Z",
    "created_at": "2021-02-09T02:54:35.429Z",
    "updated_at": "2021-02-09T03:25:01.709Z"
  }

PUT /api/developers/:id

Request

{
	"name": "Tester",
	"gender": "M",
	"age": 28,
	"hobby": "Testar",
	"birthday": "06/28/1993"
}

Response

Status: 200
{
    "id": 1,
    "name": "Tester",
    "gender": "M",
    "age": 28,
    "hobby": "Testar",
    "birthday": "1993-06-28T03:00:00.000Z",
    "created_at": "2021-02-09T02:54:35.429Z",
    "updated_at": "2021-02-09T03:25:01.709Z"
  }

DELETE /api/developers/:id

Status: 204