import { Inject, Module } from "@nestjs/common"; import { HttpAdapterHost } from "@nestjs/core"; import type { ExpressAdapter } from "@nestjs/platform-express"; import { LiveMonitorController } from "./live-monitor.controller.js"; import { LiveMonitorService } from "./live-monitor.service.js"; import { LiveMonitorPoller } from "./poller/poller.js"; import { MonitorWebhookController } from "./webhook.controller.js"; import { MonitorWebhookService, WEBHOOK_MAX_BYTES } from "./webhook.service.js"; @Module({ controllers: [LiveMonitorController, MonitorWebhookController], providers: [LiveMonitorService, LiveMonitorPoller, MonitorWebhookService], exports: [LiveMonitorService] }) export class LiveMonitorModule { constructor(@Inject(HttpAdapterHost) adapter: HttpAdapterHost) { // Installed while Nest creates modules, before init registers its default JSON parser. (adapter.httpAdapter as ExpressAdapter).useBodyParser("raw", false, { type: (request: { url?: string }) => request.url?.startsWith("/live-monitor/webhooks/") === true, limit: WEBHOOK_MAX_BYTES, inflate: false, }); } }