@@ -5,14 +5,9 @@ import { validateItem } from './person.schema.js';
5
5
class Controller {
6
6
constructor ( service ) {
7
7
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 ) ;
13
8
}
14
9
15
- async getItems ( req , res , next ) {
10
+ getItems = async ( req , res , next ) => {
16
11
try {
17
12
const result = await this . service . getItems ( req . query ) ;
18
13
res . locals = { data : result , statusCode : HTTP_STATUS . OK } ;
@@ -22,9 +17,9 @@ class Controller {
22
17
23
18
return next ( error ) ;
24
19
}
25
- }
20
+ } ;
26
21
27
- async getItemById ( req , res , next ) {
22
+ getItemById = async ( req , res , next ) => {
28
23
try {
29
24
const result = await this . service . getItemById ( parseInt ( req . params . id ) ) ;
30
25
res . locals = { data : result , statusCode : HTTP_STATUS . OK } ;
@@ -46,9 +41,9 @@ class Controller {
46
41
47
42
return next ( error ) ;
48
43
}
49
- }
44
+ } ;
50
45
51
- async createItem ( req , res , next ) {
46
+ createItem = async ( req , res , next ) => {
52
47
try {
53
48
validateItem ( req . body ) ;
54
49
const result = await this . service . createItem ( req . body ) ;
@@ -65,9 +60,9 @@ class Controller {
65
60
66
61
return next ( error ) ;
67
62
}
68
- }
63
+ } ;
69
64
70
- async updateItem ( req , res , next ) {
65
+ updateItem = async ( req , res , next ) => {
71
66
try {
72
67
validateItem ( req . body ) ;
73
68
const result = await this . service . updateItem ( parseInt ( req . params . id ) , req . body ) ;
@@ -84,9 +79,9 @@ class Controller {
84
79
85
80
return next ( error ) ;
86
81
}
87
- }
82
+ } ;
88
83
89
- async deleteItem ( req , res , next ) {
84
+ deleteItem = async ( req , res , next ) => {
90
85
try {
91
86
const result = await this . service . deleteItem ( parseInt ( req . params . id ) ) ;
92
87
res . locals = { data : result , statusCode : HTTP_STATUS . OK } ;
@@ -99,7 +94,7 @@ class Controller {
99
94
100
95
return next ( error ) ;
101
96
}
102
- }
97
+ } ;
103
98
}
104
99
105
100
export default Controller ;
0 commit comments