@nestjs-mod/webhook
Version:
Webhook module with an error filter, guard, controller, database migrations and rest-sdk for work with module from other nodejs appliaction
52 lines (51 loc) • 2.05 kB
TypeScript
import { InjectableFeatureConfigurationType } from '@nestjs-mod/common';
import { HttpService } from '@nestjs/axios';
import { Subject } from 'rxjs';
import { PrismaClient } from '../generated/prisma-client';
import { WebhookEvent } from '../types/webhook-event';
import { WebhookConfiguration, WebhookFeatureConfiguration } from '../webhook.configuration';
export declare class WebhookService<TEventName extends string = string, TEventBody = object, TEventHeaders = object> {
private readonly prismaClient;
private readonly webhookFeatureConfigurations;
private readonly webhookConfiguration;
private readonly httpService;
private readonly logger;
eventsStream$: Subject<{
eventName: TEventName;
eventBody: TEventBody;
eventHeaders: TEventHeaders;
}>;
constructor(prismaClient: PrismaClient, webhookFeatureConfigurations: InjectableFeatureConfigurationType<WebhookFeatureConfiguration>[], webhookConfiguration: WebhookConfiguration, httpService: HttpService);
sendEvent({ eventName, eventBody, eventHeaders, }: {
eventName: TEventName;
eventBody: TEventBody;
eventHeaders: TEventHeaders;
}): Promise<void>;
sendAsyncEvent({ eventName, eventBody, eventHeaders, }: {
eventName: TEventName;
eventBody: TEventBody;
eventHeaders: TEventHeaders;
}): Promise<void>;
getAllEvents(): WebhookEvent[];
sendSyncEvent({ eventName, eventBody, eventHeaders, }: {
eventName: TEventName;
eventBody: TEventBody;
eventHeaders: TEventHeaders;
}): Promise<void>;
private getCurrentDatabaseDate;
httpRequest({ endpoint, eventBody, headers, requestTimeout, }: {
endpoint: string;
eventBody: any;
headers: any;
requestTimeout: number;
}): Promise<{
response: any;
responseStatus: string;
webhookStatus: "Success" | "Error" | "Timeout";
request: {
url: string;
body: any;
headers: any;
};
}>;
}