async resolveSingleParam(wrapper, param, dependencyContext, module) {
     if (shared_utils_1.isUndefined(param)) {
         throw new undefined_dependency_exception_1.UndefinedDependencyException(wrapper.name, dependencyContext, module);
     }
     const token = this.resolveParamToken(wrapper, param);
     return this.resolveComponentInstance(module, shared_utils_1.isFunction(token) ? token.name : token, dependencyContext, wrapper);
 }
Example #2
0
 async storeRelatedModule(related, token, context) {
     if (shared_utils_1.isUndefined(related)) {
         throw new circular_dependency_exception_1.CircularDependencyException(context);
     }
     if (related && related.forwardRef) {
         return await this.container.addRelatedModule(related.forwardRef(), token);
     }
     await this.container.addRelatedModule(related, token);
 }
 await Promise.all(middlewareCollection.map(async (metatype) => {
     const collection = middlewareContainer.getMiddleware(module);
     const middleware = collection.get(metatype.name);
     if (shared_utils_1.isUndefined(middleware)) {
         throw new runtime_exception_1.RuntimeException();
     }
     const { instance } = middleware;
     await this.bindHandler(instance, metatype, applicationRef, routeInfo.method, routeInfo.path);
 }));
Example #4
0
 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();
 }
 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();
 }
Example #6
0
 createConcreteContext(metadata) {
     if (shared_utils_1.isUndefined(metadata) || shared_utils_1.isEmpty(metadata)) {
         return [];
     }
     return iterare_1.default(metadata)
         .filter((pipe) => pipe && (pipe.name || pipe.transform))
         .map(pipe => this.getPipeInstance(pipe))
         .filter(pipe => pipe && pipe.transform && shared_utils_1.isFunction(pipe.transform))
         .map(pipe => pipe.transform.bind(pipe))
         .toArray();
 }
 async bindHandler(instance, metatype, applicationRef, method, path) {
     if (shared_utils_1.isUndefined(instance.resolve)) {
         throw new invalid_middleware_exception_1.InvalidMiddlewareException(metatype.name);
     }
     const exceptionsHandler = this.routerExceptionFilter.create(instance, instance.resolve, undefined);
     const router = applicationRef.createMiddlewareFactory(method);
     const bindWithProxy = middlewareInstance => this.bindHandlerWithProxy(exceptionsHandler, router, middlewareInstance, path);
     const resolve = instance.resolve();
     const middleware = await resolve;
     bindWithProxy(middleware);
 }
 createConcreteContext(metadata) {
     if (shared_utils_1.isUndefined(metadata) || shared_utils_1.isEmpty(metadata)) {
         return [];
     }
     return iterare_1.default(metadata)
         .filter(instance => instance && (shared_utils_1.isFunction(instance.catch) || instance.name))
         .map(filter => this.getFilterInstance(filter))
         .map(instance => ({
         func: instance.catch.bind(instance),
         exceptionMetatypes: this.reflectCatchExceptions(instance),
     }))
         .toArray();
 }
 async loadInstance(wrapper, collection, module) {
     if (wrapper.isPending) {
         return wrapper.done$;
     }
     const done = this.applyDoneHook(wrapper);
     const { name, inject } = wrapper;
     const targetWrapper = collection.get(name);
     if (shared_utils_1.isUndefined(targetWrapper)) {
         throw new runtime_exception_1.RuntimeException();
     }
     if (targetWrapper.isResolved) {
         return;
     }
     const callback = async (instances) => {
         const properties = await this.resolveProperties(wrapper, module, inject);
         const instance = await this.instantiateClass(instances, wrapper, targetWrapper);
         this.applyProperties(instance, properties);
         done();
     };
     await this.resolveConstructorParams(wrapper, module, inject, callback);
 }
Example #10
0
 getCustomFactory(factory, data) {
     return !shared_utils_1.isUndefined(factory) && shared_utils_1.isFunction(factory)
         ? (req, res, next) => factory(data, req)
         : () => null;
 }