From 031314d66299855d312bda8bff9322ce628a2a50 Mon Sep 17 00:00:00 2001 From: josedario87 <71241187+josedario87@users.noreply.github.com> Date: Mon, 9 Jun 2025 15:16:02 -0600 Subject: [PATCH] refactor: isolate SSE setup --- README.md | 14 +++++++ .../20250609203423_notify_sse/migration.sql | 26 +++++++++++++ api/server.js | 4 ++ api/sse/index.js | 39 +++++++++++++++++++ ui/src/main.js | 13 ++++--- ui/src/stores/usePlanillas.js | 19 +++++++++ 6 files changed, 110 insertions(+), 5 deletions(-) create mode 100644 api/prisma/migrations/20250609203423_notify_sse/migration.sql create mode 100644 api/sse/index.js diff --git a/README.md b/README.md index 33338dc..a653664 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,20 @@ docker compose down --remove-orphans * Arranca en puerto **80** internamente. * Código fuente en `ui/src/`, configuración en `vite.config.js`. +### Notificaciones en tiempo real (SSE) + +El backend expone un endpoint `/events` que utiliza **Server-Sent Events**. La +base de datos PostgreSQL emite mensajes mediante triggers y el servidor los +reenvía a los navegadores conectados. + +```javascript +const source = new EventSource('http://localhost:4000/events'); +source.onmessage = (e) => { + const data = JSON.parse(e.data); + console.log('Evento recibido', data); +}; +``` + #### Card Animation The data cards implemented in `ui/src/components/ui/NucleoDataCard.vue` now feature a subtle growing animation when hovered over. This animation is implemented purely with CSS using keyframes and transitions defined within the component's `