REST API NodeJS desenvolvida durante a Aceleração AfroDev da Venturus by ShareRH. API de Agendamentos, com endpoints para inclusão, alteração, exclusão e listagem.
- Primeira versão da API - Desenvolvida com a bibliteca mysql executando SQL QUERY diretamente na aplicação.
- Segunda versão da API - Desenvolvida com a bibliteca sequelize como ORM executando consultas através de funções pré-definidas na biblioteca.
Para executar qualquer uma das versões da API é só clonar o projeto e dentro do diretório e executar os seguintes comandos.
yarn install ou npm install
yarn dev ou npm run dev
Exemplos de requisições e respostas dos endpoints utilizando Insomnia
GET /agendamentos
#EXEMPLO
http://localhost:3333/agendamentos
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 196
ETag: W/"3fc-Poqa1t4XKL3YZYpSvNim71CzFZI"
Date: Sat, 03 Apr 2021 03:07:25 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{
"success": true,
"schedules": [
{
"id": 1,
"customer_name": "William",
"service": "Arrumar PC",
"status": "agendado",
"service_date": "2021-04-04T03:00:00.000Z",
"scheduling_date": "2021-04-01T03:00:00.000Z"
},
]
}
GET /agendamentos/:id
#EXEMPLO
http://localhost:3333/agendamentos/1
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 196
ETag: W/"3fc-Poqa1t4XKL3YZYpSvNim71CzFZI"
Date: Sat, 03 Apr 2021 03:07:25 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{
"success":true,
"scheduling":{
"id":1,
"customer_name":"William",
"service":"Arrumar PC",
"status":"agendado",
"service_date":"2021-04-04T03:00:00.000Z",
"scheduling_date":"2021-04-01T03:00:00.000Z"
}
}
POST /agendamentos
#EXEMPLO
POST http://localhost:3333/agendamentos
BODY: Content-Type = application/json
{
"customer_name": "William",
"service": "Arrumar PC",
"status": "agendado",
"service_date": "2021-04-04"
}
HTTP/1.1 201 Created
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 167
ETag: W/"3fc-Poqa1t4XKL3YZYpSvNim71CzFZI"
Date: Sat, 03 Apr 2021 03:07:25 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{
"success":true,
"scheduling":{
"id":2,
"customer_name":"William",
"service":"Arrumar PC",
"status":"agendado",
"service_date": "2021-04-04",
"scheduling_date": "2021-04-03"
}
}
GET /agendamentos/id
#EXEMPLO
GET http://localhost:3333/agendamentos/10
HTTP/1.1 400 BAD REQUEST
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 73
ETag: W/"49-PPtgiUNZ1CEFQudqHyNsO4/leN4"
Date: Sat, 03 Apr 2021 03:15:25 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{
"success": false,
"message": "Não foi localizado agendamento com o id 10"
}
PUT /agendamentos/:id
#EXEMPLO
PUT http://localhost:3333/agendamentos/2
BODY: Content-Type = application/json
{
"service_date": "2021-04-10"
}
HTTP/1.1 202 ACCEPTED
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 98
ETag: W/"62-Mou7hjup9/D1NU3uJQ3gCyJCnyQ"
Date: Sat, 03 Apr 2021 03:23:38 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{
"success": true,
"message": "Agendamento com id 2 alterado com sucesso",
"service_date": "2021-04-10"
}
DELETE /agendamentos/id
#EXEMPLO
DELETE http://localhost:3333/agendamentos/2
HTTP/1.1 202 ACCEPTED
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 70
ETag: W/"46-6x4uwbETc5JWeKc7fCxrv7gHyzc"
Date: Sat, 03 Apr 2021 03:29:33 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{
"success": true,
"message": "Agendamento com id 2 excluido com sucesso"
}
DELETE /agendamentos/id
#EXEMPLO
DELETE http://localhost:3333/agendamentos/2
HTTP/1.1 400 BAD REQUEST
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 72
ETag: W/"48-3QkJMec06zmV+eCrfHcP3SFZ7xI"
Date: Sat, 03 Apr 2021 03:30:53 GMT
Connection: keep-alive
Keep-Alive: timeout=5
{
"success": false,
"message": "Não foi localizado agendamento com o id 7"
}
- Segurança dos endpoints com JWT
- Documentação com Swagger UI
- Deploy do servidor Heroku