54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
const express = require('express');
|
|
const app = express();
|
|
const route = '/primer_semestre';
|
|
const controllerPath = '../controller/PrimerSemestre';
|
|
const csv = require(`${controllerPath}/csv`);
|
|
const asistencia = require(`${controllerPath}/asistencia`);
|
|
const asistentes = require(`${controllerPath}/asistentes`);
|
|
const registrar = require(`${controllerPath}/registrar`);
|
|
|
|
// 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 });
|
|
});
|
|
});
|
|
|
|
app.post(`${route}/registrar`, (req, res) => {
|
|
return registrar(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
// PUT
|
|
app.put(`${route}/asistencia`, (req, res) => {
|
|
return asistencia(req.body)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
// GET
|
|
app.get(`${route}/asistentes`, (req, res) => {
|
|
return asistentes(req.query)
|
|
.then((data) => {
|
|
res.status(200).json(data);
|
|
})
|
|
.catch((err) => {
|
|
res.status(400).json({ message: err.message });
|
|
});
|
|
});
|
|
|
|
module.exports = app;
|