Skip to content

Commit e022b53

Browse files
committed
Linting
1 parent 36ec982 commit e022b53

12 files changed

+33
-36
lines changed

backend/src/auth/auth.middleware.spec.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { vi, describe, it, expect, beforeEach } from 'vitest';
66

77
describe('AuthMiddleware', () => {
88
let middleware: AuthMiddleware;
9-
let jwtService: JwtService;
109

1110
const mockJwtService = {
1211
verify: vi.fn(),
@@ -32,7 +31,6 @@ describe('AuthMiddleware', () => {
3231
}).compile();
3332

3433
middleware = module.get<AuthMiddleware>(AuthMiddleware);
35-
jwtService = module.get<JwtService>(JwtService);
3634
});
3735

3836
it('should be defined', () => {

backend/src/auth/auth.middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ConfigService } from '@nestjs/config';
77
export class AuthMiddleware implements NestMiddleware {
88
constructor(
99
private readonly jwtService: JwtService,
10-
private readonly configService: ConfigService
10+
private readonly configService: ConfigService,
1111
) {}
1212

1313
use(req: Request, res: Response, next: NextFunction) {
@@ -17,7 +17,7 @@ export class AuthMiddleware implements NestMiddleware {
1717
try {
1818
const token = authHeader.substring(7);
1919
const payload = this.jwtService.verify(token, {
20-
secret: this.configService.get<string>('JWT_SECRET')
20+
secret: this.configService.get<string>('JWT_SECRET'),
2121
});
2222

2323
req.user = {

backend/src/auth/get-user.decorator.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export const GetUser = createParamDecorator((data: unknown, ctx: ExecutionContex
77
});
88

99
// You can create a helper function to use with ApiParam
10-
export const ApiGetUser = () => ApiParam({
11-
name: 'user',
12-
description: 'User object extracted from JWT token',
13-
type: 'object',
14-
});
10+
export const ApiGetUser = () =>
11+
ApiParam({
12+
name: 'user',
13+
description: 'User object extracted from JWT token',
14+
type: 'object',
15+
});

backend/src/auth/jwt-auth.guard.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ describe('JwtAuthGuard', () => {
1818
signOptions: { expiresIn: '1h' },
1919
}),
2020
],
21-
providers: [
22-
JwtAuthGuard,
23-
JwtStrategy,
24-
],
21+
providers: [JwtAuthGuard, JwtStrategy],
2522
}).compile();
2623

2724
guard = module.get<JwtAuthGuard>(JwtAuthGuard);

backend/src/auth/user.controller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Controller, Get, Post, Body, Param, UseGuards, NotFoundException } from '@nestjs/common';
2-
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
1+
import { Controller, Get, Param, NotFoundException } from '@nestjs/common';
2+
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
33
import { User } from './user.interface';
44

55
@ApiTags('users')

backend/src/reports/dto/get-reports.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class GetReportsQueryDto {
66
@ApiProperty({
77
description: 'Maximum number of reports to return',
88
required: false,
9-
default: 10
9+
default: 10,
1010
})
1111
@IsOptional()
1212
@Type(() => Number)

backend/src/reports/dto/update-report-status.dto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class UpdateReportStatusDto {
66
@ApiProperty({
77
description: 'New status for the report',
88
enum: ReportStatus,
9-
example: ReportStatus.READ
9+
example: ReportStatus.READ,
1010
})
1111
@IsNotEmpty()
1212
@IsEnum(ReportStatus)

backend/src/reports/models/report.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class Report {
2727
@ApiProperty({
2828
description: 'Status of the report',
2929
enum: ReportStatus,
30-
default: ReportStatus.UNREAD
30+
default: ReportStatus.UNREAD,
3131
})
3232
status: ReportStatus;
3333
}

backend/src/reports/reports.controller.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ import {
66
Body,
77
Query,
88
UseGuards,
9-
ValidationPipe
9+
ValidationPipe,
1010
} from '@nestjs/common';
1111
import {
1212
ApiTags,
1313
ApiOperation,
1414
ApiResponse,
1515
ApiBearerAuth,
1616
ApiParam,
17-
ApiQuery
17+
ApiQuery,
1818
} from '@nestjs/swagger';
1919
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
2020
import { ReportsService } from './reports.service';
21-
import { Report, ReportStatus } from './models/report.model';
21+
import { Report } from './models/report.model';
2222
import { GetReportsQueryDto } from './dto/get-reports.dto';
2323
import { UpdateReportStatusDto } from './dto/update-report-status.dto';
2424

@@ -33,7 +33,7 @@ export class ReportsController {
3333
@ApiResponse({
3434
status: 200,
3535
description: 'Returns all reports',
36-
type: [Report]
36+
type: [Report],
3737
})
3838
@Get()
3939
async findAll(): Promise<Report[]> {
@@ -44,12 +44,12 @@ export class ReportsController {
4444
@ApiResponse({
4545
status: 200,
4646
description: 'Returns the latest reports',
47-
type: [Report]
47+
type: [Report],
4848
})
4949
@ApiQuery({
5050
name: 'limit',
5151
required: false,
52-
description: 'Maximum number of reports to return'
52+
description: 'Maximum number of reports to return',
5353
})
5454
@Get('latest')
5555
async findLatest(@Query(ValidationPipe) queryDto: GetReportsQueryDto): Promise<Report[]> {
@@ -60,20 +60,20 @@ export class ReportsController {
6060
@ApiResponse({
6161
status: 200,
6262
description: 'Report status updated successfully',
63-
type: Report
63+
type: Report,
6464
})
6565
@ApiResponse({
6666
status: 404,
67-
description: 'Report not found'
67+
description: 'Report not found',
6868
})
6969
@ApiParam({
7070
name: 'id',
71-
description: 'Report ID'
71+
description: 'Report ID',
7272
})
7373
@Patch(':id/status')
7474
async updateStatus(
7575
@Param('id') id: string,
76-
@Body(ValidationPipe) updateDto: UpdateReportStatusDto
76+
@Body(ValidationPipe) updateDto: UpdateReportStatusDto,
7777
): Promise<Report> {
7878
return this.reportsService.updateStatus(id, updateDto);
7979
}

backend/src/reports/reports.service.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import {
55
ScanCommand,
66
GetItemCommand,
77
UpdateItemCommand,
8-
QueryCommand
98
} from '@aws-sdk/client-dynamodb';
109
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
11-
import { Report, ReportStatus } from './models/report.model';
10+
import { Report } from './models/report.model';
1211
import { GetReportsQueryDto } from './dto/get-reports.dto';
1312
import { UpdateReportStatusDto } from './dto/update-report-status.dto';
1413

@@ -45,9 +44,9 @@ export class ReportsService {
4544
const reports = (response.Items || []).map(item => unmarshall(item) as Report);
4645

4746
// Sort by createdAt in descending order
48-
return reports.sort((a, b) =>
49-
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
50-
).slice(0, limit);
47+
return reports
48+
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())
49+
.slice(0, limit);
5150
}
5251

5352
async findOne(id: string): Promise<Report> {

0 commit comments

Comments
 (0)