- typescript
- express
- bcryptjs
- express-async-errors
- jsonwebtoken
- yup
- postgres
- typeorm
- class-transformer
- uuid
- dotenv
- cross-env
- cloudinary
- multer
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Rename and Configure the environment variables
.env.example
to.env
Install dependencies
yarn
npm install
Run the migrations
yarn migration
npm run migration
Without TOKEN authorization
POST
/login
- Request
{
"email": "example_email@gmail.com",
"password": "example_password"
}
- Response
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc0FjdGl2ZSI6dHJ1ZSwiaWF0IjoxNjY5ODQ4MDk2LCJleHAiOjE2Njk5MzQ0OTYsInN1YiI6ImYwM2ViNmMzLTg4NWUtNGQ2NS04OTZkLTRjMmJkNTdlM2RlMSJ9.UGu_Nw31sdIAoF5j7N3Z6gjK9Vu4pcYik5C3e1AKmdk",
"id": "69ca4e4a-0b63-47ff-99cb-24fff39fcbb7"
}
Status -> 201 CREATED
{
"message": "Invalid Fields"
}
Status -> 400 BADREQUEST
{
"message": "Invalid Credentials"
}
Status -> 403 FORBIDDEN
With TOKEN authorization
{
Authorization: "Bearer TOKEN"
}
POST
/advertisement
- Request
{
"title": "Example_Ads",
"year": "1360",
"km": "260600",
"price": "20603000.00",
"description": "Ads description example",
"images": [
"url",
"url"
],
"typeOfVehicle": "carro"
}
- Response
{
"title": "Example_Ads",
"year": "1360",
"km": "260600",
"price": "20603000.00",
"description": "Ads description example",
"images": [
"url",
"url"
],
"typeOfVehicle": "carro",
"user": {},
"id": "6e61bad1-ce76-493e-8ea4-50eadb46e33d",
"isActive": true,
"createdAt": "2022-12-20T11:07:59.998Z",
"updatedAt": "2022-12-20T11:07:59.998Z"
}
Status -> 201 CREATED
{
"message": "Invalid Fields"
}
Status -> 400 BADREQUEST
{
"message": "Invalid Credentials"
}
Status -> 403 FORBIDDEN
Get list
/advertisement/list
- Response
[
{
"id": "bf86b932-d7a7-4282-846f-665a59957d1a",
"title": "Example_Ads",
"year": "1360",
"km": "260600",
"price": "20603000.00",
"description": "Ads description example",
"typeOfVehicle": "carro",
"isActive": true,
"createdAt": "2022-12-19T13:16:13.860Z",
"updatedAt": "2022-12-19T13:16:13.860Z",
"coverImage": [
{
"image": "URL"
},
{
"image": "URL"
}
]
}
]
Status -> 200 OK
Get by Id
/advertisement/:id
- Response
{
"id": "bb2b51e0-90d4-4246-a318-87ac98df46e8",
"title": "Example_Ads",
"year": "1360",
"km": "260600",
"price": "20603000.00",
"description": "Ads description example",
"typeOfVehicle": "carro",
"isActive": true,
"createdAt": "2022-12-20T11:21:05.546Z",
"updatedAt": "2022-12-20T11:21:05.546Z",
"coverImage": [
{
"image": "URL"
},
{
"image": "URL"
}
]
}
Status -> 200 OK
{
"message": "Invalid Id Format"
}
Status -> 400 BADREQUEST
{
"message": "Invalid Ad Id"
}
Status -> 400 BADREQUEST
{
"message": "Id is Inactive"
}
Status -> 400 BADREQUEST
{
"message": "Invalid Credentials"
}
Status -> 403 FORBIDDEN
Update by Id
/advertisement/:id
- Request
{
"title": "Example_Updated_Ads",
"year": "1360",
"km": "2606",
"price": "150.00",
"description": "Ads updated description example",
"images":[],
"typeOfVehicle": "carro"
}
- Response
{
"id": "a47ec106-275e-419d-8bdc-0fd40cd7a8e3",
"title": "Example_Updated_Ads",
"year": "1360",
"km": "2606",
"price": "150.00",
"description": "Ads updated description example",
"typeOfVehicle": "carro",
"isActive": true,
"createdAt": "2022-12-20T11:28:10.480Z",
"updatedAt": "2022-12-20T11:31:56.043Z",
"coverImage": [
{
"image": "URL"
},{
"image": "URL"
},
]
}
Status -> 200 OK
{
"message": "Invalid Id Format"
}
Status -> 400 BADREQUEST
{
"message": "Invalid Ad Id"
}
Status -> 400 BADREQUEST
{
"message": "Id is Inactive"
}
Status -> 400 BADREQUEST
{
"message": "User credentials invalid"
}
Status -> 401 FORBIDDEN
{
"message": "Invalid Credentials"
}
Status -> 403 FORBIDDEN
Delete by Id
/advertisement/:id
- Response
Status -> 204 NOCONTENT
{
"message": "Invalid Id Format"
}
Status -> 400 BADREQUEST
{
"message": "Invalid Ad Id"
}
Status -> 400 BADREQUEST
{
"message": "Id is Inactive"
}
Status -> 400 BADREQUEST
{
"message": "User credentials invalid"
}
Status -> 401 FORBIDDEN
{
"message": "Invalid Credentials"
}
Status -> 403 FORBIDDEN