203 lines
4.5 KiB
JavaScript
203 lines
4.5 KiB
JavaScript
const express = require('express');
|
|
const app = express();
|
|
const { verificaToken } = require('../middleware/autentificacion');
|
|
const route = '/prestamo';
|
|
const controllerPath = '../controller/Prestamo';
|
|
const activos = require(`${controllerPath}/activos`);
|
|
const cancelarOperador = require(`${controllerPath}/cancelarOperador`);
|
|
const cancelarUsuario = require(`${controllerPath}/cancelarUsuario`);
|
|
const historial = require(`${controllerPath}/historial`);
|
|
const historialEquipo = require(`${controllerPath}/historialEquipo`);
|
|
const historialUsuario = require(`${controllerPath}/historialUsuario`);
|
|
const pedir = require(`${controllerPath}/pedir`);
|
|
const entregar = require(`${controllerPath}/entregar`);
|
|
const regresar = require(`${controllerPath}/regresar`);
|
|
const regresarNumeroInventario = require(`${controllerPath}/regresarNumeroInventario`);
|
|
const prestamo = require(`${controllerPath}/prestamo`);
|
|
const prestamoUsuario = require(`${controllerPath}/prestamoUsuario`);
|
|
const status = require(`${controllerPath}/status`);
|
|
|
|
app.post(
|
|
`${route}/pedir`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return pedir(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.put(
|
|
`${route}/entregar`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return entregar(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.put(
|
|
`${route}/regresar`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return regresar(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.put(
|
|
`${route}/regresar_numero_inventario`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return regresarNumeroInventario(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.put(
|
|
`${route}/cancelar_usuario`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return cancelarUsuario(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.put(
|
|
`${route}/cancelar_operador`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return cancelarOperador(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.get(
|
|
`${route}/activos`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return activos(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.get(
|
|
`${route}/historial`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return historial(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.get(
|
|
`${route}/historial_equipo`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return historialEquipo(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.get(
|
|
`${route}/historial_usuario`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return historialUsuario(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.get(
|
|
`${route}`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return prestamo(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.get(
|
|
`${route}/prestamo_usuario`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return prestamoUsuario(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
app.get(
|
|
`${route}/status`,
|
|
// verificaToken,
|
|
(req, res) => {
|
|
return status(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
}
|
|
);
|
|
|
|
module.exports = app;
|