diff --git a/src/generate/templates/opinionated/controller-service-delete.tpl b/src/generate/templates/opinionated/controller-service-delete.tpl index 7d6c0e2..3764b47 100644 --- a/src/generate/templates/opinionated/controller-service-delete.tpl +++ b/src/generate/templates/opinionated/controller-service-delete.tpl @@ -1,21 +1,13 @@ -import { BaseController, StatusCode } from "@expressots/core"; -import { controller, Delete, param, response } from "@expressots/adapter-express"; -import { Response } from "express"; +import { controller, Delete, param } from "@expressots/adapter-express"; +import { inject } from "@expressots/core"; import { {{className}}UseCase } from "./{{fileName}}.usecase"; -import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto"; @controller("/{{{route}}}") -export class {{className}}Controller extends BaseController { - constructor(private {{useCase}}UseCase: {{className}}UseCase) { - super(); - } +export class {{className}}Controller { + @inject({{className}}UseCase) private {{useCase}}UseCase: {{className}}UseCase; @Delete("/:id") - execute(@param("id") id: string, @response() res: Response): I{{className}}ResponseDTO { - return this.callUseCase( - this.{{useCase}}UseCase.execute(id), - res, - StatusCode.OK, - ); + execute(@param("id") id: string) { + return this.{{useCase}}UseCase.execute(id); } } diff --git a/src/generate/templates/opinionated/controller-service-get.tpl b/src/generate/templates/opinionated/controller-service-get.tpl index ed8ad1f..1d87d32 100644 --- a/src/generate/templates/opinionated/controller-service-get.tpl +++ b/src/generate/templates/opinionated/controller-service-get.tpl @@ -1,21 +1,13 @@ -import { BaseController, StatusCode } from "@expressots/core"; -import { controller, Get, response } from "@expressots/adapter-express"; -import { Response } from "express"; +import { controller, Get } from "@expressots/adapter-express"; +import { inject } from "@expressots/core"; import { {{className}}UseCase } from "./{{fileName}}.usecase"; -import { I{{className}}ResponseDTO } from "./{{fileName}}.dto"; @controller("/{{{route}}}") -export class {{className}}Controller extends BaseController { - constructor(private {{useCase}}UseCase: {{className}}UseCase) { - super(); - } - +export class {{className}}Controller { + @inject({{className}}UseCase) private {{useCase}}UseCase: {{className}}UseCase; + @Get("/") - execute(@response() res: Response): I{{className}}ResponseDTO { - return this.callUseCase( - this.{{useCase}}UseCase.execute(), - res, - StatusCode.OK, - ); + execute() { + return this.{{useCase}}UseCase.execute(); } } diff --git a/src/generate/templates/opinionated/controller-service-patch.tpl b/src/generate/templates/opinionated/controller-service-patch.tpl index c7dd160..8ebdc36 100644 --- a/src/generate/templates/opinionated/controller-service-patch.tpl +++ b/src/generate/templates/opinionated/controller-service-patch.tpl @@ -1,24 +1,14 @@ -import { BaseController, StatusCode } from "@expressots/core"; -import { controller, Patch, body, param, response } from "@expressots/adapter-express"; -import { Response } from "express"; +import { controller, Patch, body } from "@expressots/adapter-express"; +import { inject } from "@expressots/core"; import { {{className}}UseCase } from "./{{fileName}}.usecase"; -import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto"; +import { I{{className}}RequestDTO } from "./{{fileName}}.dto"; @controller("/{{{route}}}") -export class {{className}}Controller extends BaseController { - constructor(private {{useCase}}UseCase: {{className}}UseCase) { - super(); - } +export class {{className}}Controller { + @inject({{className}}UseCase) private {{useCase}}UseCase: {{className}}UseCase; @Patch("/") - execute( - @body() payload: I{{className}}RequestDTO, - @response() res: Response, - ): I{{className}}ResponseDTO { - return this.callUseCase( - this.{{useCase}}UseCase.execute(payload), - res, - StatusCode.OK, - ); + execute(@body() payload: I{{className}}RequestDTO) { + return this.{{useCase}}UseCase.execute(payload); } } diff --git a/src/generate/templates/opinionated/controller-service-post.tpl b/src/generate/templates/opinionated/controller-service-post.tpl index ac8481d..f9be0f0 100644 --- a/src/generate/templates/opinionated/controller-service-post.tpl +++ b/src/generate/templates/opinionated/controller-service-post.tpl @@ -1,21 +1,14 @@ -import { BaseController, StatusCode } from "@expressots/core"; -import { controller, Post, body, response } from "@expressots/adapter-express"; -import { Response } from "express"; +import { body, controller, Post } from "@expressots/adapter-express"; +import { inject } from "@expressots/core"; import { {{className}}UseCase } from "./{{fileName}}.usecase"; -import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto"; +import { I{{className}}RequestDTO } from "./{{fileName}}.dto"; @controller("/{{{route}}}") -export class {{className}}Controller extends BaseController { - constructor(private {{useCase}}UseCase: {{className}}UseCase) { - super(); - } +export class {{className}}Controller { + @inject({{className}}UseCase) private {{useCase}}UseCase: {{className}}UseCase; @Post("/") - execute(@body() payload: I{{className}}RequestDTO, @response() res: Response): I{{className}}ResponseDTO { - return this.callUseCase( - this.{{useCase}}UseCase.execute(payload), - res, - StatusCode.Created, - ); + execute(@body() payload: I{{className}}RequestDTO) { + return this.{{useCase}}UseCase.execute(payload); } } diff --git a/src/generate/templates/opinionated/controller-service-put.tpl b/src/generate/templates/opinionated/controller-service-put.tpl index 806c782..153662c 100644 --- a/src/generate/templates/opinionated/controller-service-put.tpl +++ b/src/generate/templates/opinionated/controller-service-put.tpl @@ -1,24 +1,14 @@ -import { BaseController, StatusCode } from "@expressots/core"; -import { controller, Put, body, param, response } from "@expressots/adapter-express"; -import { Response } from "express"; +import { body, controller, Put } from "@expressots/adapter-express"; +import { inject } from "@expressots/core"; import { {{className}}UseCase } from "./{{fileName}}.usecase"; -import { I{{className}}RequestDTO, I{{className}}ResponseDTO } from "./{{fileName}}.dto"; +import { I{{className}}RequestDTO } from "./{{fileName}}.dto"; @controller("/{{{route}}}") -export class {{className}}Controller extends BaseController { - constructor(private {{useCase}}UseCase: {{className}}UseCase) { - super(); - } +export class {{className}}Controller { + @inject({{className}}UseCase) private {{useCase}}UseCase: {{className}}UseCase; @Put("/") - execute( - @body() payload: I{{className}}RequestDTO, - @response() res: Response, - ): I{{className}}ResponseDTO { - return this.callUseCase( - this.{{useCase}}UseCase.execute(payload), - res, - StatusCode.OK, - ); + execute(@body() payload: I{{className}}RequestDTO) { + return this.{{useCase}}UseCase.execute(payload); } } diff --git a/src/generate/templates/opinionated/controller-service.tpl b/src/generate/templates/opinionated/controller-service.tpl index cad0b78..6969e5a 100644 --- a/src/generate/templates/opinionated/controller-service.tpl +++ b/src/generate/templates/opinionated/controller-service.tpl @@ -1,8 +1,7 @@ -import { BaseController } from "@expressots/core"; import { controller, {{method}} } from "@expressots/adapter-express"; @controller("/{{{route}}}") -export class {{className}}Controller extends BaseController { +export class {{className}}Controller { @{{method}}("/") execute() { return "Ok"; diff --git a/src/generate/templates/opinionated/module-service.tpl b/src/generate/templates/opinionated/module-service.tpl index 9ef58e7..255eeec 100644 --- a/src/generate/templates/opinionated/module-service.tpl +++ b/src/generate/templates/opinionated/module-service.tpl @@ -1,5 +1,4 @@ -import { ContainerModule } from "inversify"; -import { CreateModule } from "@expressots/core"; +import { CreateModule, ContainerModule } from "@expressots/core"; import { {{className}}Controller } from "{{{path}}}"; export const {{moduleName}}Module: ContainerModule = CreateModule([{{className}}Controller]); diff --git a/src/generate/templates/opinionated/module.tpl b/src/generate/templates/opinionated/module.tpl index 45df72d..e32c88f 100644 --- a/src/generate/templates/opinionated/module.tpl +++ b/src/generate/templates/opinionated/module.tpl @@ -1,4 +1,3 @@ -import { ContainerModule } from "inversify"; -import { CreateModule } from "@expressots/core"; +import { CreateModule, ContainerModule } from "@expressots/core"; export const {{moduleName}}Module: ContainerModule = CreateModule([]);