socket-controllers
socket-controllers copied to clipboard
fix: if controllers array is empty or undefined i have error "Cannot read property 'filter' of undefined"
Description
When i use useSocketServer(io) without controllers array in options i have error "Cannot read property 'filter' of undefined" Minimal code-snippet showcasing the problem
useSocketServer(io);
In src/index.js:36
if (options && options.controllers && options.controllers.length)
controllerClasses = (options.controllers as any[]).filter(controller => controller instanceof Function);
const controllerDirs = (options.controllers as any[]).filter(controller => typeof controller === 'string');
controllerClasses.push(...importClassesFromDirectories(controllerDirs));
please, add scopes for if
Expected behavior
doesnt get error
Actual behavior
get error
Care to open a PR?
yes
Should be fixed in the latest release.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.