Like any other provider, you need to register the provider inside start/app.js
file.
const providers = [
...
'adonisjs-sse/providers/ServerSentEventsProvider',
]
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'
}
The configuration is saved inside config/sse.js
file. Tweak it accordingly.
To find out more, read the docs here.