import { {{ className }} } from '@/application/contracts' import { Controller } from '@/application/controllers' import { HttpResponse } from '@/application/helpers' import { Validator } from '@/domain/contracts' export class {{ className }}Controller extends Controller { constructor ( private readonly decoratee: Controller, private readonly db: {{ className }} ) { super() } override buildValidators (httpRequest: any): Validator[] { return this.decoratee.buildValidators(httpRequest) } async perform (httpRequest: any): Promise { await this.db.openTransaction() try { const httpResponse = await this.decoratee.perform(httpRequest) await this.db.commit() return httpResponse } catch (error) { await this.db.rollback() throw error } finally { await this.db.closeTransaction() } } }