import { NgModule, ModuleWithProviders } from '@angular/core';
import { _MODULE_CONFIG } from './types/token';

import { CommonApiService } from './services/common-api.service';
import { ModuleConfig } from './types/module-config';

const SERVICES = [CommonApiService];

@NgModule({
  declarations: [],
  imports: [],
  exports: []
})
export class UCapCommonApiModule {
  public static forRoot(
    config: ModuleConfig
  ): ModuleWithProviders<UCapCommonApiModule> {
    return {
      ngModule: UCapCommonApiModule,
      providers: [{ provide: _MODULE_CONFIG, useValue: config }, ...SERVICES]
    };
  }
}
