import { NgModule, ModuleWithProviders } from '@angular/core';

import { PublicApiService } from './services/public-api.service';

import { _MODULE_CONFIG } from './config/token';
import { ModuleConfig } from './config/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],
    };
  }
}
