-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove BaseController inheritance and adjusting method sign…
…atures
- Loading branch information
Showing
8 changed files
with
37 additions
and
83 deletions.
There are no files selected for viewing
20 changes: 6 additions & 14 deletions
20
src/generate/templates/opinionated/controller-service-delete.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
22 changes: 7 additions & 15 deletions
22
src/generate/templates/opinionated/controller-service-get.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
24 changes: 7 additions & 17 deletions
24
src/generate/templates/opinionated/controller-service-patch.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
21 changes: 7 additions & 14 deletions
21
src/generate/templates/opinionated/controller-service-post.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
24 changes: 7 additions & 17 deletions
24
src/generate/templates/opinionated/controller-service-put.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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([]); |