@@ -10,15 +10,10 @@ export default class Controller {
1010
1111 constructor ( service : Service ) {
1212 this . service = service ;
13-
14- this . getItems = this . getItems . bind ( this ) ;
15- this . getItemById = this . getItemById . bind ( this ) ;
16- this . createItem = this . createItem . bind ( this ) ;
17- this . updateItem = this . updateItem . bind ( this ) ;
18- this . deleteItem = this . deleteItem . bind ( this ) ;
1913 }
2014
21- async getItems ( req : Request , res : Response , next : NextFunction ) : Promise < void > {
15+
16+ getItems = async ( req : Request , res : Response , next : NextFunction ) : Promise < void > => {
2217 try {
2318 const result = await this . service . getItems ( req . query ) ;
2419 res . locals = { data : result , statusCode : HTTP_STATUS . OK } ;
@@ -29,7 +24,7 @@ export default class Controller {
2924 }
3025 }
3126
32- async getItemById ( req : Request , res : Response , next : NextFunction ) : Promise < void > {
27+ getItemById = async ( req : Request , res : Response , next : NextFunction ) : Promise < void > = > {
3328 try {
3429 const id = parseInt ( req . params . id , 10 ) ;
3530 const result = await this . service . getItemById ( id ) ;
@@ -55,7 +50,7 @@ export default class Controller {
5550 }
5651 }
5752
58- async createItem ( req : Request , res : Response , next : NextFunction ) : Promise < void > {
53+ createItem = async ( req : Request , res : Response , next : NextFunction ) : Promise < void > = > {
5954 try {
6055 validateItem ( req . body ) ;
6156 const result = await this . service . createItem ( req . body as City ) ;
@@ -76,7 +71,7 @@ export default class Controller {
7671 }
7772 }
7873
79- async updateItem ( req : Request , res : Response , next : NextFunction ) : Promise < void > {
74+ updateItem = async ( req : Request , res : Response , next : NextFunction ) : Promise < void > = > {
8075 try {
8176 validateItem ( req . body ) ;
8277 const id = parseInt ( req . params . id , 10 ) ;
@@ -96,7 +91,7 @@ export default class Controller {
9691 }
9792 }
9893
99- async deleteItem ( req : Request , res : Response , next : NextFunction ) : Promise < void > {
94+ deleteItem = async ( req : Request , res : Response , next : NextFunction ) : Promise < void > = > {
10095 try {
10196 const id = parseInt ( req . params . id , 10 ) ;
10297 const result = await this . service . deleteItem ( id ) ;
0 commit comments