39 lines
996 B
JavaScript
39 lines
996 B
JavaScript
'use strict'
|
|
|
|
const Ws = use('Ws');
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Global middleware
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Global middleware are executed on each Websocket channel subscription.
|
|
|
|
|
*/
|
|
const globalMiddleware =
|
|
['Adonis/Middleware/Session', 'Adonis/Middleware/AuthInit'];
|
|
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| Named middleware
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Named middleware are defined as key/value pairs. Later you can use the
|
|
| keys to run selected middleware on a given channel.
|
|
|
|
|
| // define
|
|
| {
|
|
| auth: 'Adonis/Middleware/Auth'
|
|
| }
|
|
|
|
|
| // use
|
|
| Ws.channel('chat', 'ChatController').middleware(['auth'])
|
|
*/
|
|
const namedMiddleware = {
|
|
auth: 'Adonis/Middleware/Auth',
|
|
ws_call_auth: 'App/Middleware/WsCallAuth',
|
|
};
|
|
|
|
|
|
Ws.registerGlobal(globalMiddleware).registerNamed(namedMiddleware);
|