server_ip = 18.209.150.219
Install dependencies with:
npm install
This application uses MongoDB. To start MongoDB use:
./bin/mongod --dbpath ./data/db --directoryperdb
To introuce development data example use:
npm run install_db
To start the application in development mode use:
npm run dev
To run cluster and optimize the server use:
npm run cluster
To test clean code use:
npm run clean_code
To create a user, please post:
https://davidbragadeveloper.com/apiv1/users/addUser
To introduce the user name, email and password (all required), you must introduce body, eg.:
{
"name": "fake_name",
"email": "fake_email@example.com",
"password": "fake_password"
}
{
"succes": true,
"result": {
"_id": "5b4238rqc12ad3403fa6fecb8",
"email": "fake_email@example.com",
"password": "x7jCfjlkjasdkfjrovEKt1LOo009SEGzgml90A=",
"name": "fake_name",
"__v": 0
}
}
To authenticate a user, please post:
https://davidbragadeveloper.com/apiv1/users/login
To introduce the user email and password (all required), you must introduce body, eg.:
{
"email": "fake_email@example.com",
"password": "fake_password"
}
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIs6y35643IkpXVCJ9.eyJ1c2VyX2lkIjoiNWI0MWRmMDU2NDQwOTUwMjk2ZTg5MzBkIiwiaWF0IjoxNTMxMDY2MzQ3LCJleHAiOjE1MzEyMzkxNDd9.QxwAnfhsUnkf9pWzuALokFgowX9tYQ-3jSVeF15fmnc"
}
To query ads, please get:
https://davidbragadeveloper.com/apiv1/ads
To introduce parameters for a custom sort, you must introduce query parameters, eg.:
You must be authenticate To authenticate ?token=fake_token
To filter names use:
?name=fake_name
To filter tags use:
?tags=motor
To filter status use:
?status=sell
To filter price, you can use:
- ?price=-50 price less than 50
- ?price=10- price greater than 10
- ?price=10-50 price betwenn 10 and 50
To skip results use:
?skip=2
To sort results use:
- ?sort=field to ascending sort
- ?sort=field to descending sort
To take a limit use:
?limit=2
To choose only some fields use:
- To include a field ?fields=name
- To exclude a field ?fields=-id
{
"succes": true,
"result": [
{
"tags": [
"motor",
"mobile"
],
"_id": "5b38b12d9f1d77072de27cc7",
"name": "ad3",
"status": "search",
"price": 40.9,
"photo": "/images/image3.jpg",
"__v": 0
},
{
"tags": [
"motor",
"mobile"
],
"_id": "5b38b12d9f1d77072de27cc6",
"name": "ad2",
"status": "search",
"price": 20.3,
"photo": "/images/image2.jpg",
"__v": 0
},
{
"tags": [
"work",
"lifestyle"
],
"_id": "5b38b12d9f1d77072de27cc5",
"name": "ad1",
"status": "sell",
"price": 12.5,
"photo": "/images/image1.jpg",
"__v": 0
}
]
}
To query Tags of the Ads, please get:
https://davidbragadeveloper.com/apiv1/tags
{
"succes": true,
"result": [
"work",
"lifestyle",
"motor",
"mobile"
]
}
To get images use: