import { ExpressController, requireAuthenticatedGuard } from "@erp/core/api"; import type { UpdateCompanyRequestDTO } from "../../../../common"; import type { UpdateCompanyUseCase } from "../../../application"; import { companiesApiErrorMapper } from "../companies-api-error-mapper"; export class UpdateCompanyController extends ExpressController { public constructor(private readonly useCase: UpdateCompanyUseCase) { super(); this.errorMapper = companiesApiErrorMapper; this.registerGuards(requireAuthenticatedGuard()); } protected async executeImpl() { const { company_id } = this.req.params; if (!company_id) { return this.invalidInputError("Company ID missing"); } const dto = this.req.body as UpdateCompanyRequestDTO; const result = await this.useCase.execute({ company_id, dto }); return result.match( (data) => this.ok(data), (err) => this.handleError(err) ); } }