Nodepop is an ads API (work in progress).
You could see how it looks like by clicking the following link:
Suggestion: for VsCode users, you can download Better Comments extension for visualizing better the comments.
npm install<root-mongodb-folder>$ ./bin/mongod --dbpath ./data/db --directoryperdbLook at the .env.example to know how to declare the necessary .env variables and create a .env file
npm run db-initnpm run devTo get access to all API features, you must get the authentication token.
POST: /api/authenticate
Use the credentials in db-init.js
Payload required:
{
email: <yourEmailHere>,
password: <yourPasswordHere>,
}You will recieve a JWT Token.
GET: /api/ads
GET is limited by default to 1.000 results
- Result:
[
{
"tags": [
"lifestyle",
"motor"
],
"_id": "5e6fb453280a2b2a7bbee307",
"adName": "HoverBike",
"sale": true,
"price": 230,
"photo": "https://megaricos.com/wp-content/uploads/2018/10/Hoversurf-Hoverbike-1.jpg",
"thumbnail": "__dirname/thumbnails/name-thumbnail.jpg
"__v": 0
},
{
"tags": [
"lifestyle",
"motor",
"work"
],
"_id": "5e6fb453280a2b2a7bbee308",
"adName": "Ferrari",
"sale": true,
"price": 1500,
"photo": "https://i.pinimg.com/originals/e4/01/c7/e401c730dfdd8187340198d4a9b39b92.jpg",
"thumbnail": "__dirname/thumbnails/name-thumbnail.jpg
"__v": 0
},
]
GET: /api/ads/tags
-
Retrieve an array with all known tags from ads collection
-
Result:
[
"lifestyle",
"mobile",
"motor",
"work"
]Available filters
-
/api/ads?adName=Fooba
Starting word, non case-sensitive.
-
/api/ads?price=200
price is equal to 200
-
/api/ads?price=200-1000
price range between 200 to 1000.
-
/api/ads?price=200-
price es equal or greater than 200
-
/api/ads?price=-1000
price es equal or lower than 1000
-
/api/ads?tags=motor-lifestyle-mobile-work
tags splitted by "-".
-
/api/ads?sale=buy
or sell.
-
/api/ads?limit=2
limit the results into 2
-
/api/ads?sort=price
sort ads by price (lower to greater). With the option "-price" (greater to lower).
-
All combined:
/api/ads?adName=Fooba&price=200-1000&tags=motor-lifestyle-mobile-work&sale=buy
POST: /api/ads
- Payload required in body:
{
adName: String,
sale: Boolean,
price: Number,
photo: String,
tags: [String],
thumbnail: String, (or via Postman, in form-data body request as a type file)
}PUT: /api/ads/:id
To update an Ad, provide the id of the Ad to be modified and send the payload in the body to be modified:
- Original parameter:
{
price: 3000,
}- New parameter:
{
price: 1000,
}DELETE: /api/ads/:id
To delete an Ad provide the id parameter in URL.
- "/"
Shows the complete ads list.
- "/tags"
Shows the existing tags in all ads.
Available filters:
-
/?adName=Fooba
Starting word, non case-sensitive.
-
/?price=200
price is equal to 200
-
/?price=200-1000
price range between 200 to 1000.
-
/?price=200-
price es equal or greater than 200
-
/?price=-1000
price es equal or lower than 1000
-
/?tags=motor-lifestyle-mobile-work
tags splitted by "-".
-
/?sale=buy
or sell.
-
/?limit=2
limit the results into 2
-
/?sort=price
sort ads by price (lower to greater). With the option "-price" (greater to lower).
-
All combined:
/?adName=Fooba&price=200-1000&tags=motor-lifestyle-mobile-work&sale=buy