diff options
| author | ivanshen <iwshen11@gmail.com> | 2019-03-05 20:58:03 +0000 |
|---|---|---|
| committer | ivanshen <iwshen11@gmail.com> | 2019-03-05 20:58:03 +0000 |
| commit | 0a573cc3e918e751f5a9e02f5877f7786636539d (patch) | |
| tree | e4726c734926e0c2dc4fcf1af3c94367476bb458 /web/routes/sse.js | |
| parent | 786d0aacd27f27875568c7a89d9e1df918fadbf3 (diff) | |
Added live update functionality (feat 8)
Diffstat (limited to 'web/routes/sse.js')
| -rw-r--r-- | web/routes/sse.js | 15 |
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 |
