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

import { ProtocolService } from './services/protocol.service';
import { ModuleConfig } from './config/module-config';
import { _MODULE_CONFIG } from './config/token';

const SERVICES = [ProtocolService];

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