red-ui/libs/red-ui-http/src/lib/api.module.ts
2021-10-14 23:01:35 +03:00

54 lines
2.3 KiB
TypeScript

import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { Configuration } from './configuration';
import { HttpClient } from '@angular/common/http';
import { ManualRedactionControllerService } from './api/manualRedactionController.service';
import { ReanalysisControllerService } from './api/reanalysisController.service';
import { RedactionLogControllerService } from './api/redactionLogController.service';
import { ReportTemplateControllerService } from './api/reportTemplateController.service';
import { RulesControllerService } from './api/rulesController.service';
import { SmtpConfigurationControllerService } from './api/smtpConfigurationController.service';
import { UploadControllerService } from './api/uploadController.service';
import { ViewedPagesControllerService } from './api/viewedPagesController.service';
import { WatermarkControllerService } from './api/watermarkController.service';
import { SearchControllerService } from './api/searchController.service';
import { NotificationControllerService } from './api/notificationController.service';
@NgModule({
imports: [],
declarations: [],
exports: [],
providers: [
ManualRedactionControllerService,
ReanalysisControllerService,
RedactionLogControllerService,
ReportTemplateControllerService,
RulesControllerService,
SmtpConfigurationControllerService,
UploadControllerService,
ViewedPagesControllerService,
WatermarkControllerService,
SearchControllerService,
NotificationControllerService,
],
})
export class ApiModule {
constructor(@Optional() @SkipSelf() parentModule: ApiModule, @Optional() http: HttpClient) {
if (parentModule) {
throw new Error('ApiModule is already loaded. Import in your base AppModule only.');
}
if (!http) {
throw new Error(
'You need to import the HttpClientModule in your AppModule! \n' +
'See also https://github.com/angular/angular/issues/20575',
);
}
}
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<any> {
return {
ngModule: ApiModule,
providers: [{ provide: Configuration, useFactory: configurationFactory }],
};
}
}