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

import { PiService } from './services/pi.service';

import { _MODULE_CONFIG } from './config/token';
import { ModuleConfig } from './config/module-config';

const SERVICES = [PiService];

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