import { MetadataArgsStorage } from './metadata-builder/MetadataArgsStorage' ; import { importClassesFromDirectories } from './util/DirectoryExportedClassesLoader' ; import { SocketControllerExecutor } from './SocketControllerExecutor' ; import { SocketControllersOptions } from './SocketControllersOptions' ; /**
 * Registers all loaded actions in your express application.
 */ export function useSocketServer < T > ( io , options ? ) { createExecutor ( io , options || { } ) ; return io ; } /**
 * Registers all loaded actions in your express application.
 */ export function createSocketServer ( port , options ? ) { const io = require ( 'socket.io' ) ( port ) ; createExecutor ( io , options || { } ) ; return io ; } /**
 * Registers all loaded actions in your express application.
 */ function createExecutor ( io , options ) { const executor = new SocketControllerExecutor ( io ) ; let controllerClasses ; 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 ) ) ; let middlewareClasses ; if ( options && options . middlewares && options . middlewares . length ) { middlewareClasses = ( options . middlewares as any [ ] ) . filter ( controller => controller instanceof Function ) ; const middlewareDirs = ( options . middlewares as any [ ] ) . filter ( controller => typeof controller === 'string' ) ; middlewareClasses . push ( ... importClassesFromDirectories ( middlewareDirs ) ) ; } if ( options . useClassTransformer !== undefined ) { executor . useClassTransformer = options . useClassTransformer ; } else { executor . useClassTransformer = true ; } executor . classToPlainTransformOptions = options . classToPlainTransformOptions ; executor . plainToClassTransformOptions = options . plainToClassTransformOptions ; executor . execute ( controllerClasses , middlewareClasses ) ; } /**
 * Gets the metadata arguments storage.
 */ export function defaultMetadataArgsStorage ( ) { if ( ! ( global as any ) . socketControllersMetadataArgsStorage ) ( global as any ) . socketControllersMetadataArgsStorage = new MetadataArgsStorage ( ) ; return ( global as any ) . socketControllersMetadataArgsStorage ; } export * from './container' ; export * from './decorators' ; export * from './SocketControllersOptions' ; export * from './MiddlewareInterface' ;