Commit 0c7f0619 by Denys Tito Urbano

Router material agregado

parent 87e61265
const service = require('../services/material.service');
const get_materiales = async (req, res) => {
try {
const { aula_id, curso_id, profesor_id } = req.query;
const salida = await service.get_materiales({ aula_id, curso_id, profesor_id });
res.json(salida);
} catch (error) {
res.status(400).json({ message: error.message });
}
};
const get_material = async (req, res) => {
try {
const { drive_id, drive_encrypted } = req.query;
const salida = await service.get_material({ drive_id, drive_encrypted });
res.json(salida);
} catch (error) {
res.status(400).json({ message: error.message });
}
};
module.exports = {
get_materiales,
get_material
};
\ No newline at end of file
const connection = require('./config');
const get_materiales = async ({ aula_id, curso_id, profesor_id }) => {
return await connection.oneOrNone('SELECT * FROM academico.func_tma_material_listar ( $1, $2, $3 );', [aula_id, curso_id, profesor_id]);
};
module.exports = {
get_materiales
};
\ No newline at end of file
const express = require('express');
const router = express.Router();
const { get_materiales, get_material } = require('../controllers/material.controller');
const { validate_jwt } = require('../middlewares');
router.get('/',
validate_jwt,
get_materiales);
router.get('/recurso',
validate_jwt,
get_material);
module.exports = router;
\ No newline at end of file
......@@ -14,6 +14,7 @@ class Server {
routes() {
this.app.use('/api/auth', require('./routes/auth.router'));
this.app.use('/api/horarios', require('./routes/horario.router'));
this.app.use('/api/materiales', require('./routes/material.router'));
}
middlewares() {
......
const db = require('../db/material.db');
const axios = require('axios').default;
const get_materiales = async (input) => {
return await db.get_materiales(input);
};
const get_material = async ({ drive_id, drive_encrypted }) => {
const response = await axios.get(`${process.env.URL_TRISMEGISTO_APIS}/google/drive?drive_id=${drive_id}&drive_encrypted=${drive_encrypted}`);
return response.data;
};
module.exports = {
get_materiales,
get_material
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment