Skip to content

Commit 8c6558a

Browse files
committed
Fix lint on backend-javascript
1 parent cc5ed7f commit 8c6558a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

backend-javascript/src/modules/person/person.controller.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { HTTP_STATUS } from '../../shared/constants/http/http-status.js';
22
import { ITEM_CONSTANTS } from './person.constant.js';
33
import { validateItem } from './person.schema.js';
44

5-
65
const validatePositiveInteger = (value, fieldName = 'ID') => {
76
const parsed = parseInt(value);
87
if (isNaN(parsed) || parsed <= 0) {
98
throw new Error(`Invalid ${fieldName} parameter. Must be a positive integer.`);
109
}
10+
1111
return parsed;
1212
};
1313

@@ -34,6 +34,7 @@ class Controller {
3434

3535
const result = await this.service.getItemById(id);
3636
res.locals = { data: result, statusCode: HTTP_STATUS.OK };
37+
3738
return next();
3839

3940
} catch (error) {
@@ -46,8 +47,8 @@ class Controller {
4647
path: req.originalUrl,
4748
errorCode: HTTP_STATUS.BAD_REQUEST,
4849
timestamp: new Date().toISOString(),
49-
receivedId: req.params.id
50-
}
50+
receivedId: req.params.id,
51+
},
5152
});
5253
}
5354

@@ -73,6 +74,7 @@ class Controller {
7374
validateItem(req.body);
7475
const result = await this.service.createItem(req.body);
7576
res.locals = { data: result, statusCode: HTTP_STATUS.CREATED };
77+
7678
return next();
7779
} catch (error) {
7880
if (error.message === ITEM_CONSTANTS.ALREADY_EXISTS) {
@@ -81,6 +83,7 @@ class Controller {
8183
if (error.name === 'ValidationError') {
8284
return next({ statusCode: HTTP_STATUS.BAD_REQUEST, message: error.message });
8385
}
86+
8487
return next(error);
8588
}
8689
};
@@ -92,6 +95,7 @@ class Controller {
9295
validateItem(req.body);
9396
const result = await this.service.updateItem(id, req.body);
9497
res.locals = { data: result, statusCode: HTTP_STATUS.OK };
98+
9599
return next();
96100

97101
} catch (error) {
@@ -104,8 +108,8 @@ class Controller {
104108
path: req.originalUrl,
105109
errorCode: HTTP_STATUS.BAD_REQUEST,
106110
timestamp: new Date().toISOString(),
107-
receivedId: req.params.id
108-
}
111+
receivedId: req.params.id,
112+
},
109113
});
110114
}
111115

@@ -118,12 +122,13 @@ class Controller {
118122
path: req.originalUrl,
119123
errorCode: HTTP_STATUS.NOT_FOUND,
120124
timestamp: new Date().toISOString(),
121-
}
125+
},
122126
});
123127
}
124128
if (error.name === 'ValidationError') {
125129
return next({ statusCode: HTTP_STATUS.BAD_REQUEST, message: error.message });
126130
}
131+
127132
return next(error);
128133
}
129134
};
@@ -134,6 +139,7 @@ class Controller {
134139

135140
const result = await this.service.deleteItem(id);
136141
res.locals = { data: result, statusCode: HTTP_STATUS.OK };
142+
137143
return next();
138144

139145
} catch (error) {
@@ -146,8 +152,8 @@ class Controller {
146152
path: req.originalUrl,
147153
errorCode: HTTP_STATUS.BAD_REQUEST,
148154
timestamp: new Date().toISOString(),
149-
receivedId: req.params.id
150-
}
155+
receivedId: req.params.id,
156+
},
151157
});
152158
}
153159

@@ -160,9 +166,10 @@ class Controller {
160166
path: req.originalUrl,
161167
errorCode: HTTP_STATUS.NOT_FOUND,
162168
timestamp: new Date().toISOString(),
163-
}
169+
},
164170
});
165171
}
172+
166173
return next(error);
167174
}
168175
};

0 commit comments

Comments
 (0)