You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
524 B
28 lines
524 B
//Mock de base de datos
|
|
const store = require("./store");
|
|
|
|
function addProduct(name) {
|
|
return new Promise((resolve, reject) => {
|
|
if (!name) {
|
|
console.error(
|
|
"[productController]: No se cargó el nombre del producto!"
|
|
);
|
|
reject("Los datos son incorrectos!");
|
|
}
|
|
const product = name;
|
|
resolve(store.add(product));
|
|
});
|
|
}
|
|
|
|
function getProducts() {
|
|
return new Promise((resolve, reject) => {
|
|
resolve(store.list());
|
|
});
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
addProduct,
|
|
getProducts,
|
|
|
|
};
|
|
|