UNPKG

@dxdeveloperexperience/hygie

Version:

Hygie is an easy-to-use Open-Source REST API allowing you to interact with GIT events. This NestJS API expose a set of customizable rules to automate your project's life cycle.

39 lines (35 loc) 1.08 kB
import { Module, HttpModule, DynamicModule } from '@nestjs/common'; import { GitModule } from '../git/git.module'; import { RunnablesService } from './runnables.service'; import { Runnable } from './runnable.class'; import { Visitor } from 'universal-analytics'; import { EnvVarModule } from '../env-var/env-var.module'; export const RunnablesValues = Object.values(require('./index')).map( runnable => runnable as Runnable, ); const RunnablesProviders: any = RunnablesValues.map(runnable => ({ provide: runnable, useClass: runnable as any, })); @Module({ imports: [HttpModule, GitModule, EnvVarModule], providers: [ { provide: RunnablesService, useFactory(...runnables) { return new RunnablesService(runnables); }, inject: [...RunnablesValues], }, ...RunnablesProviders, ], exports: [RunnablesService], }) export class RunnableModule { static forRoot(analytics: Visitor): DynamicModule { return { module: RunnableModule, providers: [{ provide: 'GoogleAnalytics', useValue: analytics }], }; } }