87 lines
2.1 KiB
JavaScript
87 lines
2.1 KiB
JavaScript
const express = require('express');
|
|
const app = express();
|
|
const route = '/alumno';
|
|
const controllerPath = '../controller/Alumno';
|
|
const csv = require(`${controllerPath}/csv`);
|
|
const get = require(`${controllerPath}/get`);
|
|
const monitor = require(`${controllerPath}/monitor`);
|
|
const monitorCarreras = require(`${controllerPath}/monitorCarreras`);
|
|
const registrar = require(`${controllerPath}/registrar`);
|
|
const pasarLista = require(`${controllerPath}/pasarLista`);
|
|
const pasarListaNumeroC = require(`${controllerPath}/pasarListaNumeroC`);
|
|
|
|
// POST
|
|
app.post(`${route}/csv`, (req, res) => {
|
|
return csv(req.body)
|
|
.then((data) => {
|
|
res.download(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
// PUT
|
|
app.put(`${route}/registrar`, (req, res) => {
|
|
return registrar(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
app.put(`${route}/pasar_lista`, (req, res) => {
|
|
return pasarLista(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
app.put(`${route}/pasar_lista_numero_c`, (req, res) => {
|
|
return pasarListaNumeroC(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
// GET
|
|
app.get(`${route}`, (req, res) => {
|
|
return get(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
app.get(`${route}/monitor`, (req, res) => {
|
|
return monitor()
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
app.get(`${route}/monitor_carreras`, (req, res) => {
|
|
return monitorCarreras()
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
module.exports = app;
|