@@ -38,7 +38,7 @@ import { PrismaErrorService } from '../../shared/modules/global/prisma-error.ser
38
38
39
39
@ApiTags ( 'Appeal' )
40
40
@ApiBearerAuth ( )
41
- @Controller ( '/api/ appeals' )
41
+ @Controller ( '/appeals' )
42
42
export class AppealController {
43
43
private readonly logger : LoggerService ;
44
44
@@ -74,7 +74,10 @@ export class AppealController {
74
74
this . logger . log ( `Appeal created with ID: ${ data . id } ` ) ;
75
75
return data as AppealResponseDto ;
76
76
} catch ( error ) {
77
- const errorResponse = this . prismaErrorService . handleError ( error , 'creating appeal' ) ;
77
+ const errorResponse = this . prismaErrorService . handleError (
78
+ error ,
79
+ 'creating appeal' ,
80
+ ) ;
78
81
throw new InternalServerErrorException ( {
79
82
message : errorResponse . message ,
80
83
code : errorResponse . code ,
@@ -111,15 +114,18 @@ export class AppealController {
111
114
this . logger . log ( `Appeal updated successfully: ${ appealId } ` ) ;
112
115
return data as AppealResponseDto ;
113
116
} catch ( error ) {
114
- const errorResponse = this . prismaErrorService . handleError ( error , `updating appeal ${ appealId } ` ) ;
115
-
117
+ const errorResponse = this . prismaErrorService . handleError (
118
+ error ,
119
+ `updating appeal ${ appealId } ` ,
120
+ ) ;
121
+
116
122
if ( errorResponse . code === 'RECORD_NOT_FOUND' ) {
117
- throw new NotFoundException ( {
118
- message : `Appeal with ID ${ appealId } was not found` ,
119
- code : errorResponse . code
123
+ throw new NotFoundException ( {
124
+ message : `Appeal with ID ${ appealId } was not found` ,
125
+ code : errorResponse . code ,
120
126
} ) ;
121
127
}
122
-
128
+
123
129
throw new InternalServerErrorException ( {
124
130
message : errorResponse . message ,
125
131
code : errorResponse . code ,
@@ -147,15 +153,18 @@ export class AppealController {
147
153
this . logger . log ( `Appeal deleted successfully: ${ appealId } ` ) ;
148
154
return { message : `Appeal ${ appealId } deleted successfully.` } ;
149
155
} catch ( error ) {
150
- const errorResponse = this . prismaErrorService . handleError ( error , `deleting appeal ${ appealId } ` ) ;
151
-
156
+ const errorResponse = this . prismaErrorService . handleError (
157
+ error ,
158
+ `deleting appeal ${ appealId } ` ,
159
+ ) ;
160
+
152
161
if ( errorResponse . code === 'RECORD_NOT_FOUND' ) {
153
- throw new NotFoundException ( {
154
- message : `Appeal with ID ${ appealId } was not found` ,
155
- code : errorResponse . code
162
+ throw new NotFoundException ( {
163
+ message : `Appeal with ID ${ appealId } was not found` ,
164
+ code : errorResponse . code ,
156
165
} ) ;
157
166
}
158
-
167
+
159
168
throw new InternalServerErrorException ( {
160
169
message : errorResponse . message ,
161
170
code : errorResponse . code ,
@@ -205,15 +214,18 @@ export class AppealController {
205
214
this . logger . log ( `Appeal response created for appeal ID: ${ appealId } ` ) ;
206
215
return data . appealResponse as AppealResponseResponseDto ;
207
216
} catch ( error ) {
208
- const errorResponse = this . prismaErrorService . handleError ( error , `creating response for appeal ${ appealId } ` ) ;
209
-
217
+ const errorResponse = this . prismaErrorService . handleError (
218
+ error ,
219
+ `creating response for appeal ${ appealId } ` ,
220
+ ) ;
221
+
210
222
if ( errorResponse . code === 'RECORD_NOT_FOUND' ) {
211
- throw new NotFoundException ( {
212
- message : `Appeal with ID ${ appealId } was not found` ,
213
- code : errorResponse . code
223
+ throw new NotFoundException ( {
224
+ message : `Appeal with ID ${ appealId } was not found` ,
225
+ code : errorResponse . code ,
214
226
} ) ;
215
227
}
216
-
228
+
217
229
throw new InternalServerErrorException ( {
218
230
message : errorResponse . message ,
219
231
code : errorResponse . code ,
@@ -253,18 +265,23 @@ export class AppealController {
253
265
where : { id : appealResponseId } ,
254
266
data : mapAppealResponseRequestToDto ( body ) ,
255
267
} ) ;
256
- this . logger . log ( `Appeal response updated successfully: ${ appealResponseId } ` ) ;
268
+ this . logger . log (
269
+ `Appeal response updated successfully: ${ appealResponseId } ` ,
270
+ ) ;
257
271
return data as AppealResponseRequestDto ;
258
272
} catch ( error ) {
259
- const errorResponse = this . prismaErrorService . handleError ( error , `updating appeal response ${ appealResponseId } ` ) ;
260
-
273
+ const errorResponse = this . prismaErrorService . handleError (
274
+ error ,
275
+ `updating appeal response ${ appealResponseId } ` ,
276
+ ) ;
277
+
261
278
if ( errorResponse . code === 'RECORD_NOT_FOUND' ) {
262
- throw new NotFoundException ( {
263
- message : `Appeal response with ID ${ appealResponseId } was not found` ,
264
- code : errorResponse . code
279
+ throw new NotFoundException ( {
280
+ message : `Appeal response with ID ${ appealResponseId } was not found` ,
281
+ code : errorResponse . code ,
265
282
} ) ;
266
283
}
267
-
284
+
268
285
throw new InternalServerErrorException ( {
269
286
message : errorResponse . message ,
270
287
code : errorResponse . code ,
@@ -306,18 +323,20 @@ export class AppealController {
306
323
@Query ( 'reviewId' ) reviewId ?: string ,
307
324
@Query ( ) paginationDto ?: PaginationDto ,
308
325
) : Promise < PaginatedResponse < AppealResponseDto > > {
309
- this . logger . log ( `Getting appeals with filters - resourceId: ${ resourceId } , challengeId: ${ challengeId } , reviewId: ${ reviewId } ` ) ;
310
-
326
+ this . logger . log (
327
+ `Getting appeals with filters - resourceId: ${ resourceId } , challengeId: ${ challengeId } , reviewId: ${ reviewId } ` ,
328
+ ) ;
329
+
311
330
const { page = 1 , perPage = 10 } = paginationDto || { } ;
312
331
const skip = ( page - 1 ) * perPage ;
313
-
332
+
314
333
try {
315
334
// Build where clause for filtering
316
335
const whereClause : any = { } ;
317
336
if ( resourceId ) whereClause . resourceId = resourceId ;
318
337
if ( challengeId ) whereClause . challengeId = challengeId ;
319
338
if ( reviewId ) whereClause . appealId = reviewId ;
320
-
339
+
321
340
const [ appeals , totalCount ] = await Promise . all ( [
322
341
this . prisma . appealResponse . findMany ( {
323
342
where : whereClause ,
@@ -326,11 +345,13 @@ export class AppealController {
326
345
} ) ,
327
346
this . prisma . appealResponse . count ( {
328
347
where : whereClause ,
329
- } )
348
+ } ) ,
330
349
] ) ;
331
-
332
- this . logger . log ( `Found ${ appeals . length } appeals (page ${ page } of ${ Math . ceil ( totalCount / perPage ) } )` ) ;
333
-
350
+
351
+ this . logger . log (
352
+ `Found ${ appeals . length } appeals (page ${ page } of ${ Math . ceil ( totalCount / perPage ) } )` ,
353
+ ) ;
354
+
334
355
return {
335
356
data : appeals . map ( ( appeal ) => ( {
336
357
...appeal ,
@@ -341,10 +362,13 @@ export class AppealController {
341
362
perPage,
342
363
totalCount,
343
364
totalPages : Math . ceil ( totalCount / perPage ) ,
344
- }
365
+ } ,
345
366
} ;
346
367
} catch ( error ) {
347
- const errorResponse = this . prismaErrorService . handleError ( error , 'fetching appeals' ) ;
368
+ const errorResponse = this . prismaErrorService . handleError (
369
+ error ,
370
+ 'fetching appeals' ,
371
+ ) ;
348
372
throw new InternalServerErrorException ( {
349
373
message : errorResponse . message ,
350
374
code : errorResponse . code ,
0 commit comments