Skip to content

Commit 6075c62

Browse files
authored
Merge pull request #38 from lujakob/update-nestjs-7
Update nestjs version 7
2 parents 4d2872e + 24197be commit 6075c62

File tree

8 files changed

+2873
-1854
lines changed

8 files changed

+2873
-1854
lines changed

package-lock.json

Lines changed: 2833 additions & 1809 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,39 @@
2323
},
2424
"homepage": "https://github.com/lujakob/nestjs-realworld-example-app#readme",
2525
"dependencies": {
26-
"@nestjs/common": "^6.11.7",
27-
"@nestjs/core": "^6.11.7",
28-
"@nestjs/microservices": "^6.11.7",
29-
"@nestjs/platform-express": "^6.11.7",
30-
"@nestjs/swagger": "^3.1.0",
31-
"@nestjs/testing": "^6.11.7",
32-
"@nestjs/typeorm": "^6.3.1",
33-
"@nestjs/websockets": "^6.11.7",
34-
"argon2": "^0.26.0",
26+
"@nestjs/common": "^7.0.5",
27+
"@nestjs/core": "^7.0.5",
28+
"@nestjs/microservices": "^7.0.5",
29+
"@nestjs/platform-express": "^7.0.5",
30+
"@nestjs/swagger": "^4.4.0",
31+
"@nestjs/testing": "^7.0.5",
32+
"@nestjs/typeorm": "^7.0.0",
33+
"@nestjs/websockets": "^7.0.5",
34+
"argon2": "^0.26.1",
3535
"class-transformer": "^0.2.3",
36-
"class-validator": "^0.9.1",
36+
"class-validator": "^0.11.1",
3737
"crypto": "^1.0.1",
38-
"crypto-js": "^3.3.0",
38+
"crypto-js": "^4.0.0",
3939
"jsonwebtoken": "^8.5.1",
4040
"mysql": "^2.18.1",
4141
"passport-jwt": "^4.0.0",
4242
"reflect-metadata": "^0.1.13",
4343
"rxjs": "^6.5.4",
4444
"slug": "^1.1.0",
45-
"swagger-ui-express": "^4.1.3",
46-
"typeorm": "^0.2.22",
47-
"typescript": "^3.7.5"
45+
"swagger-ui-express": "^4.1.4",
46+
"typeorm": "^0.2.24",
47+
"typescript": "^3.8.3"
4848
},
4949
"devDependencies": {
50-
"@types/jest": "^23.3.13",
51-
"@types/node": "^10.17.15",
50+
"@types/jest": "^25.1.4",
51+
"@types/node": "^13.9.3",
5252
"atob": ">=2.1.0",
5353
"deep-extend": ">=0.5.1",
5454
"extend": ">=3.0.2",
55-
"jest": "^24.9.0",
55+
"jest": "^25.1.0",
5656
"nodemon": "^1.19.4",
5757
"supertest": "^3.4.2",
58-
"ts-jest": "^24.3.0",
59-
"ts-node": "^8.6.2"
58+
"ts-jest": "^25.2.1",
59+
"ts-node": "^8.8.1"
6060
}
6161
}

src/article/article.controller.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,27 @@ import { CommentsRO } from './article.interface';
77
import { User } from '../user/user.decorator';
88

99
import {
10-
ApiUseTags,
1110
ApiBearerAuth,
1211
ApiResponse,
13-
ApiOperation,
12+
ApiOperation, ApiTags,
1413
} from '@nestjs/swagger';
1514

1615
@ApiBearerAuth()
17-
@ApiUseTags('articles')
16+
@ApiTags('articles')
1817
@Controller('articles')
1918
export class ArticleController {
2019

2120
constructor(private readonly articleService: ArticleService) {}
2221

23-
@ApiOperation({ title: 'Get all articles' })
22+
@ApiOperation({ summary: 'Get all articles' })
2423
@ApiResponse({ status: 200, description: 'Return all articles.'})
2524
@Get()
2625
async findAll(@Query() query): Promise<ArticlesRO> {
2726
return await this.articleService.findAll(query);
2827
}
2928

3029

31-
@ApiOperation({ title: 'Get article feed' })
30+
@ApiOperation({ summary: 'Get article feed' })
3231
@ApiResponse({ status: 200, description: 'Return article feed.'})
3332
@ApiResponse({ status: 403, description: 'Forbidden.' })
3433
@Get('feed')
@@ -46,15 +45,15 @@ export class ArticleController {
4645
return await this.articleService.findComments(slug);
4746
}
4847

49-
@ApiOperation({ title: 'Create article' })
48+
@ApiOperation({ summary: 'Create article' })
5049
@ApiResponse({ status: 201, description: 'The article has been successfully created.'})
5150
@ApiResponse({ status: 403, description: 'Forbidden.' })
5251
@Post()
5352
async create(@User('id') userId: number, @Body('article') articleData: CreateArticleDto) {
5453
return this.articleService.create(userId, articleData);
5554
}
5655

57-
@ApiOperation({ title: 'Update article' })
56+
@ApiOperation({ summary: 'Update article' })
5857
@ApiResponse({ status: 201, description: 'The article has been successfully updated.'})
5958
@ApiResponse({ status: 403, description: 'Forbidden.' })
6059
@Put(':slug')
@@ -63,23 +62,23 @@ export class ArticleController {
6362
return this.articleService.update(params.slug, articleData);
6463
}
6564

66-
@ApiOperation({ title: 'Delete article' })
65+
@ApiOperation({ summary: 'Delete article' })
6766
@ApiResponse({ status: 201, description: 'The article has been successfully deleted.'})
6867
@ApiResponse({ status: 403, description: 'Forbidden.' })
6968
@Delete(':slug')
7069
async delete(@Param() params) {
7170
return this.articleService.delete(params.slug);
7271
}
7372

74-
@ApiOperation({ title: 'Create comment' })
73+
@ApiOperation({ summary: 'Create comment' })
7574
@ApiResponse({ status: 201, description: 'The comment has been successfully created.'})
7675
@ApiResponse({ status: 403, description: 'Forbidden.' })
7776
@Post(':slug/comments')
7877
async createComment(@Param('slug') slug, @Body('comment') commentData: CreateCommentDto) {
7978
return await this.articleService.addComment(slug, commentData);
8079
}
8180

82-
@ApiOperation({ title: 'Delete comment' })
81+
@ApiOperation({ summary: 'Delete comment' })
8382
@ApiResponse({ status: 201, description: 'The article has been successfully deleted.'})
8483
@ApiResponse({ status: 403, description: 'Forbidden.' })
8584
@Delete(':slug/comments/:id')
@@ -88,15 +87,15 @@ export class ArticleController {
8887
return await this.articleService.deleteComment(slug, id);
8988
}
9089

91-
@ApiOperation({ title: 'Favorite article' })
90+
@ApiOperation({ summary: 'Favorite article' })
9291
@ApiResponse({ status: 201, description: 'The article has been successfully favorited.'})
9392
@ApiResponse({ status: 403, description: 'Forbidden.' })
9493
@Post(':slug/favorite')
9594
async favorite(@User('id') userId: number, @Param('slug') slug) {
9695
return await this.articleService.favorite(userId, slug);
9796
}
9897

99-
@ApiOperation({ title: 'Unfavorite article' })
98+
@ApiOperation({ summary: 'Unfavorite article' })
10099
@ApiResponse({ status: 201, description: 'The article has been successfully unfavorited.'})
101100
@ApiResponse({ status: 403, description: 'Forbidden.' })
102101
@Delete(':slug/favorite')

src/profile/profile.controller.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { ProfileRO } from './profile.interface';
55
import { User } from '../user/user.decorator';
66

77
import {
8-
ApiUseTags,
9-
ApiBearerAuth,
8+
ApiBearerAuth, ApiTags,
109
} from '@nestjs/swagger';
1110

1211
@ApiBearerAuth()
13-
@ApiUseTags('profiles')
12+
@ApiTags('profiles')
1413
@Controller('profiles')
1514
export class ProfileController {
1615

src/shared/pipes/validation.pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {PipeTransform, ArgumentMetadata, BadRequestException, HttpStatus, Injectable} from '@nestjs/common';
22
import { validate } from 'class-validator';
33
import { plainToClass } from 'class-transformer';
4-
import {HttpException} from "@nestjs/common/exceptions/http.exception";
4+
import { HttpException } from '@nestjs/common/exceptions/http.exception';
55

66
@Injectable()
77
export class ValidationPipe implements PipeTransform<any> {

src/tag/tag.controller.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { TagEntity } from './tag.entity';
44
import { TagService } from './tag.service';
55

66
import {
7-
ApiUseTags,
8-
ApiBearerAuth,
7+
ApiBearerAuth, ApiTags,
98
} from '@nestjs/swagger';
109

1110
@ApiBearerAuth()
12-
@ApiUseTags('tags')
11+
@ApiTags('tags')
1312
@Controller('tags')
1413
export class TagController {
1514

src/user/user.controller.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import { Get, Post, Body, Put, Delete, Param, Controller, UsePipes } from '@nestjs/common';
22
import { Request } from 'express';
33
import { UserService } from './user.service';
4-
import { UserEntity } from './user.entity';
54
import { UserRO } from './user.interface';
65
import { CreateUserDto, UpdateUserDto, LoginUserDto } from './dto';
76
import { HttpException } from '@nestjs/common/exceptions/http.exception';
87
import { User } from './user.decorator';
98
import { ValidationPipe } from '../shared/pipes/validation.pipe';
109

1110
import {
12-
ApiUseTags,
13-
ApiBearerAuth
11+
ApiBearerAuth, ApiTags
1412
} from '@nestjs/swagger';
1513

1614
@ApiBearerAuth()
17-
@ApiUseTags('user')
15+
@ApiTags('user')
1816
@Controller()
1917
export class UserController {
2018

src/user/user.decorator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { createParamDecorator } from '@nestjs/common';
1+
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
22
import { SECRET } from '../config';
33
import * as jwt from 'jsonwebtoken';
44

5-
export const User = createParamDecorator((data, req) => {
5+
export const User = createParamDecorator((data: any, ctx: ExecutionContext) => {
6+
const req = ctx.switchToHttp().getRequest();
67
// if route is protected, there is a user set in auth.middleware
78
if (!!req.user) {
89
return !!data ? req.user[data] : req.user;
@@ -14,5 +15,4 @@ export const User = createParamDecorator((data, req) => {
1415
const decoded: any = jwt.verify(token[1], SECRET);
1516
return !!data ? decoded[data] : decoded.user;
1617
}
17-
1818
});

0 commit comments

Comments
 (0)