Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 908 Bytes

instructions.md

File metadata and controls

40 lines (28 loc) · 908 Bytes

Registering provider

Like any other provider, you need to register the provider inside start/app.js file.

const providers = [
  ...
  'adonisjs-sse/providers/ServerSentEventsProvider',
]

Registering middleware

Register the following middleware inside start/kernel.js file.

You can optionally place the sse middleware after the 'Adonis/Middleware/AuthInit' middleware

const globalMiddleware = [
  ...
  'Adonis/Middleware/AuthInit',
  'Adonis/Middleware/EventSourceWatcher'
]

Or alternatively setup the middleware as a named (use any name you feel like) middleware inside start/kernel.js file.

const namedMiddleware = {
  eventsource: 'Adonis/Middleware/EventSourceWatcher'
}

Config

The configuration is saved inside config/sse.js file. Tweak it accordingly.

Docs

To find out more, read the docs here.