aboutsummaryrefslogtreecommitdiff
path: root/web/routes/sse.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/routes/sse.js')
-rw-r--r--web/routes/sse.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/web/routes/sse.js b/web/routes/sse.js
new file mode 100644
index 0000000..5cd9a3f
--- /dev/null
+++ b/web/routes/sse.js
@@ -0,0 +1,15 @@
+module.exports = function (req, res, next) {
+ res.sseSetup = function() {
+ res.writeHead(200, {
+ 'Content-Type': 'text/event-stream',
+ 'Cache-Control': 'no-cache',
+ 'Connection': 'keep-alive'
+ })
+ }
+
+ res.sseSend = function(data) {
+ res.write("data: " + JSON.stringify(data) + "\n\n");
+ }
+
+ next()
+} \ No newline at end of file