chore(): export more items

This commit is contained in:
Morb0 2021-01-06 17:54:49 +03:00
parent 3e10acf070
commit c32f2c72d9
3 changed files with 45 additions and 2 deletions

View File

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

View File

@ -2,5 +2,8 @@ export * from './decorators';
export * from './interfaces'; export * from './interfaces';
export * from './utils'; export * from './utils';
export * from './types'; export * from './types';
export * from './services';
export * from './errors';
export * from './execution-context';
export * from './telegraf.constants'; export * from './telegraf.constants';
export * from './telegraf.module'; export * from './telegraf.module';

View File

@ -131,7 +131,47 @@ export class ListenersExplorerService
methodName, methodName,
); );
// TODO: Add callback to middleware and handle return data const { method, args } = metadata;
composer[method](...args, (ctx: unknown, next: Function) => {
const deferredResult = listenerCallbackFn(ctx, next);
console.log(deferredResult);
});
/*
this.telegraf[method](
...args,
async (ctx: Context, next: () => Promise<void>) => {
const defferedResult = contextHandlerFn.call(instance, ctx, next);
const result = this.pickResult(defferedResult);
fromPromise(result)
.pipe(
mergeAll(),
filter((response: any) => !isNil(response)),
)
.subscribe((text) => {
// TODO: More processing method return logic (files, images, etc)
// Example: https://github.com/nestjs/nest/blob/01dc358aade27d3d7ca510506696aa62bfb1cc43/packages/platform-socket.io/adapters/io-adapter.ts#L56
return ctx.reply(text);
});
},
);
private async pickResult(
defferedResult: Promise<any>,
): Promise<Observable<any>> {
const result = await defferedResult;
if (result && isFunction(result.subscribe)) {
return result;
}
if (result instanceof Promise) {
return fromPromise(result);
}
return of(result);
}
*/
} }
createContextCallback<T extends Record<string, unknown>>( createContextCallback<T extends Record<string, unknown>>(