MatthewWid/better-sse

Hapi support

Closed this issue · 1 comments

This topic of SSE comes up here and there in Hapi slack. Would be cool to see hapi support. Hapi offers the raw req/res from the http built-in, and allows you to fully take over the request handling using the h.abandon symbol. Might be interesting to see a decoration that handles the usage:

{
  ...,
  handler(req, h) {
    // implicitly returns h.abandon. Pushes are handled in the callback
    return h.betterSse(req.raw, (sse) => {

      sse.push(...);
    });
  }
}

Above is pseudocode but just an endresult idea that might be interesting.

Hapi offers the raw req/res from the http built-in, and allows you to fully take over the request handling using the h.abandon symbol.

This package should work out of the box in that case.

I've now added an example of using Hapi in the recipes section of the documentation 🙂.