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

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

const SERVICES = [PublicApiService];

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