feat: implement injectbot decorator

This commit is contained in:
Aleksandr Bukhalo 2020-05-03 11:06:25 +03:00
parent beeffc5088
commit 6361e537aa
5 changed files with 12 additions and 4 deletions

View File

@ -1,3 +1,4 @@
export * from './inject-bot.decorator';
export * from './telegraf-use.decorator'; export * from './telegraf-use.decorator';
export * from './telegraf-on.decorator'; export * from './telegraf-on.decorator';
export * from './telegraf-hears.decorator'; export * from './telegraf-hears.decorator';

View File

@ -0,0 +1,4 @@
import { Inject } from '@nestjs/common';
import { TELEGRAF_PROVIDER } from '../telegraf.constants';
export const InjectBot = (): ParameterDecorator => Inject(TELEGRAF_PROVIDER);

View File

@ -5,6 +5,7 @@ export * as session from 'telegraf/session';
export * as Stage from 'telegraf/stage'; export * as Stage from 'telegraf/stage';
export * as WizardScene from 'telegraf/scenes/wizard'; export * as WizardScene from 'telegraf/scenes/wizard';
export * from './telegraf.module';
export * from './interfaces';
export * from './decorators'; export * from './decorators';
export * from './interfaces';
export * from './telegraf.module';
export * from './telegraf.provider';

View File

@ -1,3 +1,4 @@
import { DiscoveryModule } from '@nestjs/core';
import { Module, DynamicModule, Provider, Type } from '@nestjs/common'; import { Module, DynamicModule, Provider, Type } from '@nestjs/common';
import { import {
TelegrafModuleOptions, TelegrafModuleOptions,
@ -10,7 +11,6 @@ import {
} from './telegraf.constants'; } from './telegraf.constants';
import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor'; import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
import { TelegrafExplorer } from './telegraf.explorer'; import { TelegrafExplorer } from './telegraf.explorer';
import { DiscoveryModule } from '@nestjs/core';
import { TelegrafProvider } from './telegraf.provider'; import { TelegrafProvider } from './telegraf.provider';
@Module({ @Module({

View File

@ -7,10 +7,11 @@ import {
@Module({}) @Module({})
export class TelegrafModule { export class TelegrafModule {
public static forRoot(options?: TelegrafModuleOptions): DynamicModule { public static forRoot(options: TelegrafModuleOptions): DynamicModule {
return { return {
module: TelegrafModule, module: TelegrafModule,
imports: [TelegrafCoreModule.forRoot(options)], imports: [TelegrafCoreModule.forRoot(options)],
exports: [TelegrafCoreModule],
}; };
} }
@ -20,6 +21,7 @@ export class TelegrafModule {
return { return {
module: TelegrafModule, module: TelegrafModule,
imports: [TelegrafCoreModule.forRootAsync(options)], imports: [TelegrafCoreModule.forRootAsync(options)],
exports: [TelegrafCoreModule],
}; };
} }
} }