erp-clinicas-backend-v2/src/modules/payment-terminals/payment-terminals.module.ts
Adrian Flores Cortes 289b4eb466 [PROP-CORE-004] fix: Remove external entity references from payment-terminals
Fixed getEntities() to only reference own entities, avoiding require errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 03:08:27 -06:00

73 lines
2.5 KiB
TypeScript

/**
* Payment Terminals Module
*
* Module registration for payment terminals and transactions
* Includes: MercadoPago, Clip, Stripe Terminal
*/
import { Router } from 'express';
import { DataSource } from 'typeorm';
import {
TerminalsController,
TransactionsController,
MercadoPagoController,
MercadoPagoWebhookController,
ClipController,
ClipWebhookController,
} from './controllers';
export interface PaymentTerminalsModuleOptions {
dataSource: DataSource;
basePath?: string;
}
export class PaymentTerminalsModule {
public router: Router;
public webhookRouter: Router;
private terminalsController: TerminalsController;
private transactionsController: TransactionsController;
private mercadoPagoController: MercadoPagoController;
private mercadoPagoWebhookController: MercadoPagoWebhookController;
private clipController: ClipController;
private clipWebhookController: ClipWebhookController;
constructor(options: PaymentTerminalsModuleOptions) {
const { dataSource, basePath = '' } = options;
this.router = Router();
this.webhookRouter = Router();
// Initialize controllers
this.terminalsController = new TerminalsController(dataSource);
this.transactionsController = new TransactionsController(dataSource);
this.mercadoPagoController = new MercadoPagoController(dataSource);
this.mercadoPagoWebhookController = new MercadoPagoWebhookController(dataSource);
this.clipController = new ClipController(dataSource);
this.clipWebhookController = new ClipWebhookController(dataSource);
// Register authenticated routes
this.router.use(`${basePath}/payment-terminals`, this.terminalsController.router);
this.router.use(`${basePath}/payment-transactions`, this.transactionsController.router);
this.router.use(`${basePath}/mercadopago`, this.mercadoPagoController.router);
this.router.use(`${basePath}/clip`, this.clipController.router);
// Register public webhook routes (no auth required)
this.webhookRouter.use('/mercadopago', this.mercadoPagoWebhookController.router);
this.webhookRouter.use('/clip', this.clipWebhookController.router);
}
/**
* Get all entities for this module (for TypeORM configuration)
*/
static getEntities() {
return [
require('./entities/tenant-terminal-config.entity').TenantTerminalConfig,
require('./entities/terminal-payment.entity').TerminalPayment,
require('./entities/terminal-webhook-event.entity').TerminalWebhookEvent,
];
}
}
export default PaymentTerminalsModule;