aboutsummaryrefslogtreecommitdiff
path: root/web/routes/sse.js
blob: 5cd9a3fc3441d1beb17e6043d73a0e6cbe26bd6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()
}