feat: implement SSE real-time frontend updates on new payload reception
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 57s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 57s
This commit is contained in:
@@ -143,6 +143,12 @@ app.post('/api/data', authenticateAPIKey, async (req, res) => {
|
||||
}
|
||||
|
||||
await client.query('COMMIT');
|
||||
|
||||
// Broadcast update to all connected SSE clients
|
||||
const broadcastMessage = `data: {"type": "update"}\n\n`;
|
||||
for (const clientRes of sseClients) {
|
||||
clientRes.write(broadcastMessage);
|
||||
}
|
||||
} catch (error) {
|
||||
await client.query('ROLLBACK');
|
||||
console.error("Database insert error:", error);
|
||||
@@ -152,6 +158,13 @@ app.post('/api/data', authenticateAPIKey, async (req, res) => {
|
||||
})();
|
||||
});
|
||||
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`Nexstar Backend running at http://localhost:${PORT}`);
|
||||
console.log(`Endpoint for n8n: POST http://localhost:${PORT}/api/data`);
|
||||
}); }
|
||||
})();
|
||||
});
|
||||
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`Nexstar Backend running at http://localhost:${PORT}`);
|
||||
console.log(`Endpoint for n8n: POST http://localhost:${PORT}/api/data`);
|
||||
|
||||
Reference in New Issue
Block a user