red-ui/libs/red-ui-http/src/lib/api.module.ts
2021-10-06 19:54:29 +03:00

70 lines
3.3 KiB
TypeScript

import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { Configuration } from './configuration';
import { HttpClient } from '@angular/common/http';
import { DownloadControllerService } from './api/downloadController.service';
import { FileManagementControllerService } from './api/fileManagementController.service';
import { GeneralSettingsControllerService } from './api/generalSettingsController.service';
import { InfoControllerService } from './api/infoController.service';
import { LegalBasisMappingControllerService } from './api/legalBasisMappingController.service';
import { LicenseReportControllerService } from './api/licenseReportController.service';
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 { VersionsControllerService } from './api/versionsController.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';
import { StatusReportControllerService } from './api/statusReportController.service';
@NgModule({
imports: [],
declarations: [],
exports: [],
providers: [
DownloadControllerService,
FileManagementControllerService,
GeneralSettingsControllerService,
InfoControllerService,
LegalBasisMappingControllerService,
LicenseReportControllerService,
ManualRedactionControllerService,
ReanalysisControllerService,
RedactionLogControllerService,
ReportTemplateControllerService,
RulesControllerService,
SmtpConfigurationControllerService,
UploadControllerService,
VersionsControllerService,
ViewedPagesControllerService,
WatermarkControllerService,
SearchControllerService,
NotificationControllerService,
StatusReportControllerService,
],
})
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 }],
};
}
}