npm install
Copy .env.example to .env and review your config.
Only on first deploy:
npm run initDB
To start a single instance:
npm start
To start in development mode:
npm run dev
El API inicialmente tendrá al menos dos usuarios:
● admin@example.com, clave 1234
● user1@example.com, clave 1234
Permite hacer login en el API retornando un JWT
{
"tokenJWT": // "the generated web token"
}
Retorna una lista de productos con algún filtro (p.e. por nombre), paginación, ordenación y selección de campos. Solo devuelve los productos que son propiedad del usuario logado.
{
"results": [
{
"_id": "6783a9f23c9dff4f56732fd3",
"name": "Bicicleta",
"owner": "6783a9f23c9dff4f56732fcd",
"price": 23015,
"tags": [
"lifestyle",
"motor"
],
"__v": 0
},
// ...
],
"count": 2
}
Retorna un producto
http://localhost:3000/api/products/6783a9f23c9dff4f56732fd4
{
"result": {
"_id": "6783a9f23c9dff4f56732fd4",
"name": "Iphone",
"owner": "6783a9f23c9dff4f56732fcd",
"price": 5000,
"tags": [
"lifestyle",
"mobile"
],
"__v": 0
}
}
Crea un producto, con subida de imágen
{
"result": {
"name": "prueba",
"price": 4850,
"tags": [],
"_id": "6783ac131975f7e4bb3953bf",
"owner": "6783a9f23c9dff4f56732fcd",
"__v": 0
}
}
Actualiza un producto
http://localhost:3000/api/products/6783a9f23c9dff4f56732fd4
{
"result": {
"_id": "6783a9f23c9dff4f56732fd4",
"name": "patatas",
"owner": "6783a9f23c9dff4f56732fcd",
"price": 5000,
"tags": [
"lifestyle",
"mobile"
],
"__v": 0
}
}
Elimina un producto
http://localhost:3000/api/products/6783a9f23c9dff4f56732fd4