aboutsummaryrefslogtreecommitdiff
path: root/web/routes/sse.js
diff options
context:
space:
mode:
authorKumar Damani <damani.kumar@gmail.com>2019-03-08 21:50:43 +0000
committerGitHub <noreply@github.com>2019-03-08 21:50:43 +0000
commita51529eccd60120c34aafe9da9aea0d48750a325 (patch)
treea553e2619100942911e8a1235a63086cc25c091d /web/routes/sse.js
parentb254c15754fbcf00457167e6c51dc0e3bfcc083f (diff)
parent032fc2bea5f5c00d4147e4077107f52888b302c4 (diff)
Merge pull request #31 from csc301-winter-2019/qa
Qa
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