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.
38 lines
786 B
38 lines
786 B
//Mock de base de datos
|
|
const store = require("./store");
|
|
|
|
function addFirmware(productID, label, version, filepath) {
|
|
return new Promise((resolve, reject) => {
|
|
if (!productID || !label || !version || !filepath) {
|
|
console.error(
|
|
"[firmwareController]: No se cargaron todos los datos del firmware!"
|
|
);
|
|
reject("No se cargaron todos los datos del firmware!");
|
|
}
|
|
const path = '/data/binarios/' + filepath;
|
|
const firmware = {
|
|
productID: productID,
|
|
label: label,
|
|
version: version,
|
|
filepath: path
|
|
}
|
|
|
|
resolve(store.add(firmware));
|
|
});
|
|
}
|
|
|
|
function getFirmwares() {
|
|
return new Promise((resolve, reject) => {
|
|
resolve(store.list());
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
addFirmware,
|
|
getFirmwares,
|
|
|
|
};
|
|
|