initial commit

This commit is contained in:
Alexander Bukhalo
2022-11-20 14:13:48 +03:00
parent 1bb274e8e2
commit 2d23eba148
94 changed files with 65 additions and 17013 deletions

View File

@@ -1,3 +0,0 @@
export * from './tg-arguments-host.interface';
export * from './telegraf-arguments-host';
export * from './telegraf-execution-context';

View File

@@ -1,23 +0,0 @@
import { ArgumentsHost } from '@nestjs/common';
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
import { TgArgumentsHost } from './tg-arguments-host.interface';
export class TelegrafArgumentsHost
extends ExecutionContextHost
implements TgArgumentsHost
{
static create(context: ArgumentsHost): TelegrafArgumentsHost {
const type = context.getType();
const tgContext = new TelegrafArgumentsHost(context.getArgs());
tgContext.setType(type);
return tgContext;
}
getContext<T = any>(): T {
return this.getArgByIndex(0);
}
getNext<T = any>(): T {
return this.getArgByIndex(1);
}
}

View File

@@ -1,33 +0,0 @@
import { ContextType, ExecutionContext } from '@nestjs/common';
import { ExecutionContextHost } from '@nestjs/core/helpers/execution-context-host';
import { TgArgumentsHost } from './tg-arguments-host.interface';
export type TelegrafContextType = 'telegraf' | ContextType;
export class TelegrafExecutionContext
extends ExecutionContextHost
implements TgArgumentsHost
{
static create(context: ExecutionContext): TelegrafExecutionContext {
const type = context.getType();
const tgContext = new TelegrafExecutionContext(
context.getArgs(),
context.getClass(),
context.getHandler(),
);
tgContext.setType(type);
return tgContext;
}
getType<TContext extends string = TelegrafContextType>(): TContext {
return super.getType();
}
getContext<T = any>(): T {
return this.getArgByIndex(0);
}
getNext<T = any>(): T {
return this.getArgByIndex(1);
}
}

View File

@@ -1,6 +0,0 @@
import { ArgumentsHost } from '@nestjs/common';
export interface TgArgumentsHost extends ArgumentsHost {
getContext<T = any>(): T;
getNext<T = any>(): T;
}