2020-11-15 22:49:00 -06:00
|
|
|
const express = require('express');
|
|
|
|
|
const app = express();
|
2021-01-05 15:34:00 -06:00
|
|
|
const { verificaToken } = require('../middleware/autentificacion');
|
2020-11-23 12:56:24 -06:00
|
|
|
const route = '/cuestionario_programa';
|
2021-05-05 18:49:23 -05:00
|
|
|
const controllerPath = '../controller/CuestionarioPrograma';
|
|
|
|
|
const get = require(`${controllerPath}/get`);
|
2021-05-13 14:06:07 -05:00
|
|
|
const nuevo = require(`${controllerPath}/nuevo`);
|
2020-11-15 22:49:00 -06:00
|
|
|
|
2021-05-13 14:06:07 -05:00
|
|
|
// POST
|
2021-01-05 18:27:38 -06:00
|
|
|
app.post(`${route}`, verificaToken, (req, res) => {
|
2020-11-23 12:56:24 -06:00
|
|
|
return nuevo(req.body)
|
|
|
|
|
.then((data) => {
|
|
|
|
|
res.status(200).json(data);
|
|
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
2020-11-23 13:56:58 -06:00
|
|
|
res.status(400).json({ message: err.message });
|
2020-11-23 12:56:24 -06:00
|
|
|
});
|
|
|
|
|
});
|
2020-11-15 22:49:00 -06:00
|
|
|
|
2021-05-13 14:06:07 -05:00
|
|
|
// GET
|
2021-01-11 04:54:21 -06:00
|
|
|
app.get(`${route}`, verificaToken, (req, res) => {
|
|
|
|
|
return get(req.query)
|
|
|
|
|
.then((data) => {
|
2021-05-12 19:08:28 -05:00
|
|
|
res.download(data);
|
2021-01-11 04:54:21 -06:00
|
|
|
})
|
|
|
|
|
.catch((err) => {
|
|
|
|
|
res.status(400).json({ message: err.message });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2020-11-15 22:49:00 -06:00
|
|
|
module.exports = app;
|