Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createInjector(settings: any = {}) {
const injector = new InjectorService();
// Init settings
injector.settings = createSettingsService(injector);
injector.logger = $log;
injector.settings.scopes = {
...(settings.scopes || {}),
[ProviderType.CONTROLLER]: settings.controllerScope
};
// @ts-ignore
injector.settings.set(settings);
/* istanbul ignore next */
if (injector.settings.env === "test") {
injector.logger.stop();
}
return injector;
}
before(() => {
this.handlerMetadata = {
type: ProviderType.CONTROLLER,
target: "target"
};
this.handlerBuilder = new HandlerBuilder(this.handlerMetadata);
this.buildHandlerStub = Sinon.stub(this.handlerBuilder, "buildHandler");
this.buildHandlerStub.returns("endpointHandler");
this.result = this.handlerBuilder.getHandler();
});
it("should have called the middlewareHandler method", () => {
constructor(provide: any) {
super(provide);
this.type = ProviderType.CONTROLLER;
}
constructor(
private injectorService: InjectorService,
@Configuration() private settings: Configuration,
private routeService: RouteService
) {
super(injectorService as any, {filter: {type: ProviderType.CONTROLLER}});
}
constructor(injector: InjectorService) {
const routers = injector
.getProviders(ProviderType.CONTROLLER)
.map(provider => {
if (!provider.hasParent()) {
return new ControllerBuilder(provider as ControllerProvider).build(injector);
}
})
.filter(Boolean);
return {routers};
}
}