Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 2x 1x 1x 1x 1x 2x | const router = require("express").Router(); const HiloController = require('../controllers/HiloController'); // POST // Endpoint de crear un Hilo. // http://localhost:5500/hilos router.post("/", async (req, res) => { try { const body = req.body; let respuesta = await HiloController.crearHilo(body); res.status(respuesta.status).json(respuesta.datos); } catch (error) { return res.status(400).json({ message: error.message }); } }); // GET // Endpoint de mostrar Todos los Hilos. // http://localhost:5500/ router.get("/", async (req, res) => { try { let respuesta = await HiloController.traerHilos(); res.status(respuesta.status).json(respuesta.datos); } catch (error) { return res.status(500).json({ message: error.message }); } }); // GET // Endpoint de mostrar un Hilo por ID. // http://localhost:5500/hilos/:id router.get("/:id", async (req, res) => { try { let id = req.params.id let respuesta = await HiloController.traerHiloId(id); res.status(respuesta.status).json(respuesta.datos); } catch (error) { return res.status(500).json({ message: error.message }); } }); // GET // Endpoint de mostrar los likes de un Hilo por ID. // http://localhost:5500/hilos/:id/likes router.get('/:id/likes', async (req, res) => { try { let id = req.params.id let respuesta = await HiloController.getLikesDeHilo(id); res.status(respuesta.status).json(respuesta.datos); } catch (error) { return res.status(500).json({ message: error.message }); } }) // PATCH // Endpoint de Modificar el Hilo por ID. // http://localhost:5500/hilos/:id router.patch("/:id", async (req, res) => { try { const id = req.params.id; const body = req.body; let respuesta = await HiloController.cambiaHilo(id, body) res.status(respuesta.status).json(respuesta.datos); } catch (error) { return res.status(500).json({ message: error.message }); } }); // DELETE // Endpoint de borrar un Hilo por ID. // http://localhost:5500/hilos/:id router.delete("/:id", async (req, res) => { try { const id = req.params.id; let respuesta = await HiloController.borrarHilo(id); res.status(respuesta.status).json(respuesta.datos); } catch (error) { return res.status(500).json({ message: error.message }); } }); module.exports = router; |