Desafio Brave Ag - Back-end 🚀
Desafio realizado utilizando as seguintes tecnologias:
- Node.JS;
- Sequelize;
- Express;
- Mysql;
- Sinon.JS;
- Chai;
- Sequelize-test-helpers.
Instale as dependências e adicione as variáveis de ambiente para acessar o banco
npm install
npx sequelize db:create
npx sequelize db:migrate
npx sequelize db:seed:all
npm start
- Não é necessário rodar a API no momento do teste. O próprio chai-http, subirá a API.
npm test
Method |
endpoint |
status code |
GET |
/articles |
200 |
{
"count": 1,
"rows": [
{
"id": 1,
"title": "title",
"content": "content",
"url": "big",
"big": "hot",
"hot": "uploads/1640106327646.png",
"createdAt": "2021-12-21T17:05:27.651Z",
"updatedAt": "2021-12-21T17:05:27.651Z"
},
]
}
Method |
endpoint |
status code |
GET |
/articles/:id |
200 |
GET |
/articles/?title=string |
200 |
GET |
/articles/?order=string |
200 |
{
"id": 1,
"title": "title",
"content": "content",
"url": "big",
"big": "hot",
"hot": "uploads/1640106327646.png",
"createdAt": "2021-12-21T17:05:27.651Z",
"updatedAt": "2021-12-21T17:05:27.651Z"
}
Method |
endpoint |
status code |
POST |
/articles |
201 |
Property |
Description |
type |
title |
article title |
String |
content |
Article content |
String |
url |
url image |
String |
big |
big description |
String |
hot |
hot description |
String |
Method |
endpoint |
status code |
PUT |
/articles/:id |
204 |
Property |
Description |
type |
title |
article title |
String |
content |
Article content. |
String |
url |
url image |
String |
big |
big description |
String |
hot |
hot description |
String |
Method |
endpoint |
status code |
DELETE |
/articles/:id |
204 |
The request has no body response.
Method |
endpoint |
status code |
GET |
/hero |
200 |
{
"count": 1,
"rows": [
{
"id": 1,
"content": "content test",
"createdAt": "2021-12-19T23:13:34.008Z",
"updatedAt": "2021-12-21T14:26:34.279Z"
},
]
}
Method |
endpoint |
status code |
GET |
/hero/:id |
200 |
GET |
/hero/?content=string |
200 |
GET |
/hero/?order=string |
200 |
{
"id": 1,
"content": "content test",
"createdAt": "2021-12-19T23:13:34.008Z",
"updatedAt": "2021-12-21T14:26:34.279Z"
}
Method |
endpoint |
status code |
POST |
/hero |
201 |
Property |
Description |
type |
content |
hero content |
String |
Method |
endpoint |
status code |
PUT |
/hero/:id |
204 |
Property |
Description |
type |
content |
hero content |
String |
Method |
endpoint |
status code |
DELETE |
/hero/:id |
204 |
The request has no body response.
Method |
endpoint |
status code |
GET |
/contacts |
200 |
{
"count": 1,
"rows": [
{
"id": 2,
"name": "Placehold 01",
"email": "email@email.com",
"createdAt": "2021-12-19T01:04:51.949Z",
"updatedAt": "2021-12-19T01:04:51.949Z"
},
]
}
Method |
endpoint |
status code |
GET |
/contacts/:id |
200 |
GET |
/contacts/?name=string |
200 |
GET |
/contacts/?order=string |
200 |
{
"id": 2,
"name": "Placehold 02",
"email": "email@email.com",
"createdAt": "2021-12-19T01:04:51.949Z",
"updatedAt": "2021-12-19T01:04:51.949Z"
}
Method |
endpoint |
status code |
POST |
/contacts |
201 |
Property |
Description |
type |
name |
name contact |
String |
email |
email contact |
String |
Method |
endpoint |
status code |
PUT |
/contacts/:id |
204 |
Property |
Description |
type |
name |
name contact |
String |
email |
email contact |
String |
Method |
endpoint |
status code |
DELETE |
/contacts/:id |
204 |
The request has no body response.
Contato