Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
applyMiddlewares(server, components, tokens) {
const adapter = this.config.getIoAdapter();
iterare_1.default(tokens)
.map(token => this.bindMiddleware(token.name, components))
.filter(middleware => !shared_utils_1.isNil(middleware))
.forEach(middleware => adapter.bindMiddleware(server, middleware));
}
bindMiddleware(token, components) {
scanFromPrototype(instance, prototype, callback) {
return iterare_1.default([...this.getAllFilteredMethodNames(prototype)])
.map(callback)
.filter(metadata => !shared_utils_1.isNil(metadata))
.toArray();
}
*getAllFilteredMethodNames(prototype) {
callModuleDestroyHook(module) {
const components = [...module.routes, ...module.components];
iterare_1.default(components)
.map(([key, { instance }]) => instance)
.filter(instance => !shared_utils_1.isNil(instance))
.filter(this.hasOnModuleDestroyHook)
.forEach(instance => instance.onModuleDestroy());
}
hasOnModuleDestroyHook(instance) {
createGlobalMetadataContext(metadata) {
return iterare_1.default(metadata)
.filter(guard => guard && guard.canActivate && shared_utils_1.isFunction(guard.canActivate))
.toArray();
}
getInstanceByMetatype(metatype) {
createConcreteContext(metadata) {
if (shared_utils_1.isUndefined(metadata) || shared_utils_1.isEmpty(metadata) || !this.moduleContext) {
return [];
}
const isGlobalMetadata = metadata === this.getGlobalMetadata();
return isGlobalMetadata
? this.createGlobalMetadataContext(metadata)
: iterare_1.default(metadata)
.filter((metatype) => metatype && metatype.name)
.map(metatype => this.getInstanceByMetatype(metatype))
.filter((wrapper) => wrapper && wrapper.instance)
.map(wrapper => wrapper.instance)
.filter((interceptor) => interceptor && shared_utils_1.isFunction(interceptor.intercept))
.toArray();
}
createGlobalMetadataContext(metadata) {
createConcreteContext(metadata) {
if (shared_utils_1.isUndefined(metadata) || shared_utils_1.isEmpty(metadata)) {
return [];
}
return iterare_1.default(metadata)
.filter((interceptor) => interceptor && (interceptor.name || interceptor.intercept))
.map(interceptor => this.getInterceptorInstance(interceptor))
.filter((interceptor) => interceptor && shared_utils_1.isFunction(interceptor.intercept))
.toArray();
}
getInterceptorInstance(interceptor) {
createConcreteContext(metadata) {
if (shared_utils_1.isUndefined(metadata) || shared_utils_1.isEmpty(metadata)) {
return [];
}
return iterare_1.default(metadata)
.filter((guard) => guard && (guard.name || guard.canActivate))
.map(guard => this.getGuardInstance(guard))
.filter((guard) => guard && shared_utils_1.isFunction(guard.canActivate))
.toArray();
}
getGuardInstance(guard) {
createGlobalMetadataContext(metadata) {
return iterare_1.default(metadata)
.filter(interceptor => interceptor &&
interceptor.intercept &&
shared_utils_1.isFunction(interceptor.intercept))
.toArray();
}
getInstanceByMetatype(metatype) {
createConcreteContext(metadata) {
if (shared_utils_1.isUndefined(metadata) || shared_utils_1.isEmpty(metadata)) {
return [];
}
return iterare_1.default(metadata)
.filter(pipe => pipe && pipe.transform && shared_utils_1.isFunction(pipe.transform))
.map(pipe => pipe.transform.bind(pipe))
.toArray();
}
getGlobalMetadata() {
callModuleDestroyHook(module) {
const components = [...module.routes, ...module.components];
iterare_1.default(components)
.map(([key, { instance }]) => instance)
.filter(instance => !shared_utils_1.isNil(instance))
.filter(this.hasOnModuleDestroyHook)
.forEach(instance => instance.onModuleDestroy());
}
hasOnModuleDestroyHook(instance) {