Files
clube67_newwhats.local/clube67/newwhats.local/plugins/ext-api/index.js
T
VPS 4 Deploy Agent 2f8c04a0a7
continuous-integration/webhook Falha no deploy de clube67_newwhats.local (VPS 4)
chore(ops): restore all source files in newwhats.clube67.com
2026-05-18 03:28:29 +02:00

36 lines
2.2 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const apikey_auth_1 = require("./backend/apikey-auth");
const routes_1 = require("./backend/routes");
const ws_bridge_1 = require("./backend/ws-bridge");
const webhook_dispatcher_1 = require("./backend/webhook-dispatcher");
const manifest_json_1 = __importDefault(require("./manifest.json"));
const plugin = {
manifest: manifest_json_1.default,
async activate(ctx) {
const { app, prisma, db, config, hooks, logger, httpServer } = ctx;
// ── REST ────────────────────────────────────────────────────────────────
const manager = globalThis.__whatsAppManager;
if (!manager) {
logger.warn('[ext-api] WhatsAppConnectionManager não disponível via globalThis.__whatsAppManager — endpoints de send desativados');
}
const authMiddleware = (0, apikey_auth_1.buildApiKeyAuth)(prisma);
const extRouter = (0, routes_1.buildExtRoutes)(prisma, manager, db, config, hooks);
app.use('/api/ext/v1', authMiddleware, extRouter);
logger.info('[ext-api] Rotas REST registradas em /api/ext/v1');
// ── WS Bridge ───────────────────────────────────────────────────────────
(0, ws_bridge_1.buildWsBridge)(httpServer, prisma, hooks);
logger.info('[ext-api] WS bridge ativo em /api/ext/v1/stream (x-nw-key auth)');
// ── Webhook Dispatcher ──────────────────────────────────────────────────
(0, webhook_dispatcher_1.buildWebhookDispatcher)(prisma, hooks);
logger.info('[ext-api] Webhook dispatcher ativo');
},
async deactivate(ctx) {
ctx.logger.warn('[ext-api] Desativado. Reinicie o servidor para remover as rotas.');
},
};
exports.default = plugin;
//# sourceMappingURL=index.js.map