Skip to content

Commit 5e91d71

Browse files
committed
Fix linter
1 parent 51b5423 commit 5e91d71

File tree

5 files changed

+40
-25
lines changed

5 files changed

+40
-25
lines changed

src/main.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ async function bootstrap() {
1010
});
1111

1212
app.enableShutdownHooks();
13-
app.useGlobalPipes(new ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true }));
13+
app.useGlobalPipes(
14+
new ValidationPipe({
15+
whitelist: true,
16+
forbidNonWhitelisted: true,
17+
transform: true,
18+
}),
19+
);
1420

15-
const port = process.env.PORT ?? 3000
21+
const port = process.env.PORT ?? 3000;
1622

1723
const config = new DocumentBuilder()
1824
.setTitle('TypeScript NestJS Template')
@@ -27,4 +33,4 @@ async function bootstrap() {
2733
await app.listen(port);
2834
}
2935

30-
bootstrap();
36+
void bootstrap();

src/users/entities/user.entity.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface User {
2-
id: number;
3-
name: string;
4-
email: string;
2+
id: number;
3+
name: string;
4+
email: string;
55
}

src/users/users.controller.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { Body, Controller, Get, Post } from '@nestjs/common';
2-
import { ApiCreatedResponse, ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
2+
import {
3+
ApiCreatedResponse,
4+
ApiOkResponse,
5+
ApiOperation,
6+
ApiTags,
7+
} from '@nestjs/swagger';
38
import { UsersService } from './users.service';
49
import { CreateUserDto } from './dto/create-user.dto';
510
import type { User } from './entities/user.entity';
611

712
@ApiTags('User')
813
@Controller('/api/v1/users')
914
export class UsersController {
10-
constructor(private readonly usersService: UsersService) {
11-
}
15+
constructor(private readonly usersService: UsersService) {}
1216

1317
@Post()
1418
@ApiOperation({ summary: 'Create User' })

src/users/users.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Injectable, Logger } from '@nestjs/common';
22
import { CreateUserDto } from './dto/create-user.dto';
3-
import { User } from "./entities/user.entity";
3+
import { User } from './entities/user.entity';
44

55
@Injectable()
66
export class UsersService {

test/users.e2e-spec.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Test, TestingModule } from '@nestjs/testing';
22
import { INestApplication, ValidationPipe } from '@nestjs/common';
33
import request from 'supertest';
4-
import { AppModule } from '../src/app.module';
4+
import { AppModule } from 'src/app.module';
5+
import { User } from 'src/users/entities/user.entity';
56

67
describe('UsersModule (e2e)', () => {
78
let app: INestApplication;
@@ -12,11 +13,13 @@ describe('UsersModule (e2e)', () => {
1213
}).compile();
1314

1415
app = moduleFixture.createNestApplication();
15-
app.useGlobalPipes(new ValidationPipe({
16-
whitelist: true,
17-
forbidNonWhitelisted: true,
18-
transform: true,
19-
}));
16+
app.useGlobalPipes(
17+
new ValidationPipe({
18+
whitelist: true,
19+
forbidNonWhitelisted: true,
20+
transform: true,
21+
}),
22+
);
2023
await app.init();
2124
});
2225

@@ -26,27 +29,29 @@ describe('UsersModule (e2e)', () => {
2629
email: 'simone@example.com',
2730
};
2831

32+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
2933
const res = await request(app.getHttpServer())
3034
.post('/api/v1/users')
3135
.send(userDto)
3236
.expect(201);
3337

34-
expect(res.body).toEqual({
35-
id: expect.any(Number),
36-
name: userDto.name,
37-
email: userDto.email,
38-
});
38+
const user = res.body as User;
39+
expect(typeof user.id).toBe('number');
40+
expect(user.name).toBe(userDto.name);
41+
expect(user.email).toBe(userDto.email);
3942
});
4043

4144
it('/api/v1/users (GET) should return all users', async () => {
45+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
4246
const res = await request(app.getHttpServer())
4347
.get('/api/v1/users')
4448
.expect(200);
4549

46-
expect(Array.isArray(res.body)).toBe(true);
47-
expect(res.body[0]).toHaveProperty('id');
48-
expect(res.body[0]).toHaveProperty('name');
49-
expect(res.body[0]).toHaveProperty('email');
50+
const users = res.body as User[];
51+
expect(Array.isArray(users)).toBe(true);
52+
expect(users[0]).toHaveProperty('id');
53+
expect(users[0]).toHaveProperty('name');
54+
expect(users[0]).toHaveProperty('email');
5055
});
5156

5257
afterAll(async () => {

0 commit comments

Comments
 (0)