import { authGuard, ExpressController, forbidQueryFieldGuard, tenantGuard } from "@erp/core/api"; import { DeleteCustomerInvoiceUseCase } from "../../../application"; import { customerInvoicesApiErrorMapper } from "../customer-invoices-api-error-mapper"; export class DeleteCustomerInvoiceController extends ExpressController { public constructor( private readonly useCase: DeleteCustomerInvoiceUseCase /* private readonly presenter: any */ ) { super(); this.errorMapper = customerInvoicesApiErrorMapper; // 🔐 Reutiliza guards de auth/tenant y prohíbe 'companyId' en query this.registerGuards(authGuard(), tenantGuard(), forbidQueryFieldGuard("companyId")); } async executeImpl() { const tenantId = this.getTenantId()!; // garantizado por tenantGuard const { id } = this.req.params; const result = await this.useCase.execute({ id, tenantId }); return result.match( (data) => this.ok(data), (err) => this.handleError(err) ); } }