Evaluarion test for backend Dev using nodejs + mongoDB
MongoDB has to be installed in your computer
cd store-api
mongorestore ~/wherever/your/project/is/database/first_backup/
npm install
node server/server
https://documenter.getpostman.com/view/4649025/S1ENzed2
POST : localhost:3000/product
body : {
"name" : "crackers",
"description":"cookies",
"price" : 0.95,
"quantity" : 12
}
headers: {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
{{token}} : should be changed by a valid token
to get a new token you must need to get login with a valid user, only users with ADMIN_ROLES can perform this action
DELETE : localhost:3000/product/{{id}}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
{{token}} : should be changed by a valid token
to get a new token you must need to get login with a valid user, only users with ADMIN_ROLES can perform this action
PUT : localhost:3000/product/stock/{{id}}
body : {
"quantity" : 11
}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
{{id}} : should be changed by a valid product id
{{token}} : should be changed by a valid token
to get a new token you must need to get login with a valid user, only users with ADMIN_ROLES can perform this action
PUT : localhost:3000/product/price/{{id}}
body : {
"price" : 0.95
}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
{{id}} : should be changed by a valid product id
{{token}} : should be changed by a valid token
to get a new token you must need to get login with a valid user, only users with ADMIN_ROLES can perform this action
PUT : localhost:3000/product/purchase/{{id}}
body : {
"quantity" : 1
}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
{{id}} : should be changed by a valid product id
{{token}} : should be changed by a valid token
to get a new token you must need to get login with a valid user, only users with ADMIN_ROLES can perform this action
POST : localhost:3000/like/{{id}}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
{{id}} : should be changed by a valid product id
{{token}} : should be changed by a valid token
to get a new token you must need to get login with a valid user, only users with ADMIN_ROLES can perform this action
GET : localhost:3000/product/availables?from={{from}}&step={{step}}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
List of Available Products. {{from}} : is the initial boundary, by default is zero if you don't pass the key-pair value {{step}} : is the final boundary, by default is 5 if you don't pass the key-pair value
GET : localhost:3000/product/search/{{name}}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
{{name}} need to be change by a name, it doesn't matter if is just one part of a name.
POST : localhost:3000/user
body : {
"name" : "Ambar Artiga",
"email" : "Ambar@gmail.com",
"password" : "qwerty1234",
"role" : "USER_ROLE"
}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
This is helpful to create a new user and their roles. the Actual Valid Roles are : ADMIN_ROLE USER_ROLE
POST : localhost:3000/login?email={{email}}&password={{password}}
headers : {
Content-Type : "application/x-www-form-urlencoded",
token : {{token}}
}
login and get a valid token to get access to many apis {{email}}: the email need to be change for a valid that exists in the DB {{password}} : need to be change for the password that come along with the email as well
GET :
- localhost:3000/products
- localhost:3000/likes
- localhost:3000/log/prices/product
- localhost:3000/log/prices/product/{{id}}
- localhost:3000/log/purchase/products
- localhost:3000/log/purchase/products/{{id}}