mirror of
https://github.com/strapi/strapi.git
synced 2025-07-13 12:02:10 +00:00
33 lines
413 B
JavaScript
33 lines
413 B
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
/**
|
||
|
* WebSockets hook
|
||
|
*/
|
||
|
|
||
|
module.exports = function (strapi) {
|
||
|
const hook = {
|
||
|
|
||
|
/**
|
||
|
* Default options
|
||
|
*/
|
||
|
|
||
|
defaults: {
|
||
|
websockets: true
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* Initialize the hook
|
||
|
*/
|
||
|
|
||
|
initialize: function (cb) {
|
||
|
if (strapi.config.websockets === true) {
|
||
|
global.io = require('socket.io')(strapi.app);
|
||
|
}
|
||
|
|
||
|
cb();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
return hook;
|
||
|
};
|