@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
50 lines • 1.87 kB
JavaScript
;
var WebhookServiceBootstrap_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebhookServiceBootstrap = void 0;
const tslib_1 = require("tslib");
const common_1 = require("@nestjs-mod/common");
const common_2 = require("@nestjs/common");
const rxjs_1 = require("rxjs");
const webhook_service_1 = require("./webhook.service");
let WebhookServiceBootstrap = WebhookServiceBootstrap_1 = class WebhookServiceBootstrap {
constructor(webhookService) {
this.webhookService = webhookService;
this.logger = new common_2.Logger(WebhookServiceBootstrap_1.name);
}
async onModuleInit() {
this.logger.debug('onModuleInit');
if ((0, common_1.isInfrastructureMode)()) {
return;
}
}
onModuleDestroy() {
if (this.eventsRef) {
this.eventsRef.unsubscribe();
this.eventsRef = undefined;
}
}
async onApplicationBootstrap() {
this.logger.debug('onApplicationBootstrap');
if ((0, common_1.isInfrastructureMode)()) {
return;
}
this.subscribeToEvents();
}
subscribeToEvents() {
if (this.eventsRef) {
this.eventsRef.unsubscribe();
this.eventsRef = undefined;
}
this.eventsRef = this.webhookService.eventsStream$
.asObservable()
.pipe((0, rxjs_1.concatMap)(async (options) => this.webhookService.sendSyncEvent(options)))
.subscribe();
}
};
exports.WebhookServiceBootstrap = WebhookServiceBootstrap;
exports.WebhookServiceBootstrap = WebhookServiceBootstrap = WebhookServiceBootstrap_1 = tslib_1.__decorate([
(0, common_2.Injectable)(),
tslib_1.__metadata("design:paramtypes", [webhook_service_1.WebhookService])
], WebhookServiceBootstrap);
//# sourceMappingURL=webhook-bootstrap.service.js.map