@@ -5,14 +5,15 @@ import { validateItem } from './city.schema.js';
55class Controller {
66 constructor ( service ) {
77 this . service = service ;
8- this . getItems = this . getItems . bind ( this ) ;
9- this . getItemById = this . getItemById . bind ( this ) ;
10- this . createItem = this . createItem . bind ( this ) ;
11- this . updateItem = this . updateItem . bind ( this ) ;
12- this . deleteItem = this . deleteItem . bind ( this ) ;
8+ // this.getItems = this.getItems.bind(this);
9+ // this.getItemById = this.getItemById.bind(this);
10+ // this.createItem = this.createItem.bind(this);
11+ // this.updateItem = this.updateItem.bind(this);
12+ // this.deleteItem = this.deleteItem.bind(this);
1313 }
1414
15- async getItems ( req , res , next ) {
15+ // async getItems(req, res, next) {
16+ getItems = async ( req , res , next ) => {
1617 try {
1718 const result = await this . service . getItems ( req . query ) ;
1819 res . locals = { data : result , statusCode : HTTP_STATUS . OK } ;
@@ -24,7 +25,7 @@ class Controller {
2425 }
2526 }
2627
27- async getItemById ( req , res , next ) {
28+ getItemById = async ( req , res , next ) => {
2829 try {
2930 const result = await this . service . getItemById ( parseInt ( req . params . id ) ) ;
3031 res . locals = { data : result , statusCode : HTTP_STATUS . OK } ;
@@ -48,7 +49,7 @@ class Controller {
4849 }
4950 }
5051
51- async createItem ( req , res , next ) {
52+ createItem = async ( req , res , next ) => {
5253 try {
5354 validateItem ( req . body ) ;
5455 const result = await this . service . createItem ( req . body ) ;
@@ -67,7 +68,7 @@ class Controller {
6768 }
6869 }
6970
70- async updateItem ( req , res , next ) {
71+ updateItem = async ( req , res , next ) => {
7172 try {
7273 validateItem ( req . body ) ;
7374 const result = await this . service . updateItem ( parseInt ( req . params . id ) , req . body ) ;
@@ -86,7 +87,7 @@ class Controller {
8687 }
8788 }
8889
89- async deleteItem ( req , res , next ) {
90+ deleteItem = async ( req , res , next ) => {
9091 try {
9192 const result = await this . service . deleteItem ( parseInt ( req . params . id ) ) ;
9293 res . locals = { data : result , statusCode : HTTP_STATUS . OK } ;
0 commit comments