refactor(wip): remove core module & change tokens

This commit is contained in:
unknown
2020-12-26 14:54:10 +03:00
parent c85460dc10
commit 80853be80c
26 changed files with 155 additions and 185 deletions

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafUpdateType } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface OnOptions {
*/
export const On = (updateTypes: TelegrafUpdateType): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.On),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.On),
SetMetadata(LISTENER_OPTIONS_METADATA, {
updateTypes,
} as OnOptions),
);

View File

@@ -1,8 +1,9 @@
import { SetMetadata } from '@nestjs/common';
import { TELEGRAF_UPDATE } from '../../telegraf.constants';
import { TELEGRAF_UPDATE_METADATA } from '../../telegraf.constants';
/**
* `@Update` decorator, it's like NestJS `@Controller` decorator,
* but for Telegram Bot API updates.
*/
export const Update = (): ClassDecorator => SetMetadata(TELEGRAF_UPDATE, true);
export const Update = (): ClassDecorator =>
SetMetadata(TELEGRAF_UPDATE_METADATA, true);

View File

@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=use
*/
export const Use = (): MethodDecorator => {
return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Use);
return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Use);
};

View File

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

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { TelegrafActionTriggers } from '../../telegraf.types';
import { ListenerType } from '../../enums/listener-type.enum';
@@ -17,8 +17,8 @@ export interface ActionOptions {
*/
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Action),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Action),
SetMetadata(LISTENER_OPTIONS_METADATA, {
triggers,
} as ActionOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { TelegrafCashtag } from '../../telegraf.types';
import { ListenerType } from '../../enums/listener-type.enum';
@@ -17,8 +17,8 @@ export interface CashtagOptions {
*/
export const Cashtag = (cashtag: TelegrafCashtag): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Cashtag),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Cashtag),
SetMetadata(LISTENER_OPTIONS_METADATA, {
cashtag,
} as CashtagOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafCommand } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface CommandOptions {
*/
export const Command = (command: TelegrafCommand): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Command),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Command),
SetMetadata(LISTENER_OPTIONS_METADATA, {
command: command,
} as CommandOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafEmail } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface EmailOptions {
*/
export const Email = (email: TelegrafEmail): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Email),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Email),
SetMetadata(LISTENER_OPTIONS_METADATA, {
email,
} as EmailOptions),
);

View File

@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=inlinequery
*/
export const GameQuery = (): MethodDecorator => {
return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.GameQuery);
return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.GameQuery);
};

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafHashtag } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface HashtagOptions {
*/
export const Hashtag = (hashtag: TelegrafHashtag): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Hashtag),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Hashtag),
SetMetadata(LISTENER_OPTIONS_METADATA, {
hashtag,
} as HashtagOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafHearsTriggers } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface HearsOptions {
*/
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Hears),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Hears),
SetMetadata(LISTENER_OPTIONS_METADATA, {
triggers,
} as HearsOptions),
);

View File

@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=help
*/
export const Help = (): MethodDecorator => {
return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Help);
return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Help);
};

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafInlineQueryTriggers } from '../../telegraf.types';
@@ -19,8 +19,8 @@ export const InlineQuery = (
triggers: TelegrafInlineQueryTriggers,
): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.InlineQuery),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.InlineQuery),
SetMetadata(LISTENER_OPTIONS_METADATA, {
triggers,
} as InlineQueryOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafMention } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface MentionOptions {
*/
export const Mention = (mention: TelegrafMention): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Mention),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Mention),
SetMetadata(LISTENER_OPTIONS_METADATA, {
mention,
} as MentionOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafPhone } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface PhoneOptions {
*/
export const Phone = (phone: TelegrafPhone): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Phone),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Phone),
SetMetadata(LISTENER_OPTIONS_METADATA, {
phone,
} as PhoneOptions),
);

View File

@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=settings
*/
export const Settings = (): MethodDecorator => {
return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Settings);
return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Settings);
};

View File

@@ -1,5 +1,5 @@
import { SetMetadata } from '@nestjs/common';
import { TELEGRAF_LISTENER_TYPE } from '../../telegraf.constants';
import { LISTENER_TYPE_METADATA } from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
/**
@@ -8,5 +8,5 @@ import { ListenerType } from '../../enums/listener-type.enum';
* @see https://telegraf.js.org/#/?id=start
*/
export const Start = (): MethodDecorator => {
return SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Start);
return SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Start);
};

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextLink } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface TextLinkOptions {
*/
export const TetxLink = (link: TelegrafTextLink): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextLink),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.TextLink),
SetMetadata(LISTENER_OPTIONS_METADATA, {
link,
} as TextLinkOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextMention } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface TextMentionOptions {
*/
export const TetxMention = (mention: TelegrafTextMention): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextMention),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.TextMention),
SetMetadata(LISTENER_OPTIONS_METADATA, {
mention,
} as TextMentionOptions),
);

View File

@@ -1,7 +1,7 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
LISTENER_OPTIONS_METADATA,
LISTENER_TYPE_METADATA,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafUrl } from '../../telegraf.types';
@@ -17,8 +17,8 @@ export interface UrlOptions {
*/
export const Url = (url: TelegrafUrl): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Url),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
SetMetadata(LISTENER_TYPE_METADATA, ListenerType.Url),
SetMetadata(LISTENER_OPTIONS_METADATA, {
url,
} as UrlOptions),
);