You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,7 @@
2
2
3
3
### 0.8.0
4
4
5
-
- rename `@Param` and `@Params` decorators to `@PathParam` and `@PathParams` (#289)
6
-
- restore/introduce `@QueryParams()` and `@PathParams()` missing decorators options (they are needed for validation purposes) (#289)
5
+
- restore/introduce `@QueryParams()` and `@Params()` missing decorators options (they are needed for validation purposes) (#289)
7
6
- normalize param object properties (for "queries", "headers", "params" and "cookies") - now you can easily validate query/path params using `class-validator` (#289)
8
7
- enhance params normalization - converting from string to primitive types is now more strict and can throw ParamNormalizationError,
9
8
e.g. when number is expected but the invalid string (NaN) has been received (#289)
@@ -627,7 +627,7 @@ This action will return 404 in the case if user was not found, and regular 200 i
627
627
```typescript
628
628
@Get("/users/:id")
629
629
@OnUndefined(404)
630
-
getOne(@PathParam("id") id: number) {
630
+
getOne(@Param("id") id: number) {
631
631
returnuserRepository.findOneById(id);
632
632
}
633
633
```
@@ -647,7 +647,7 @@ export class UserNotFoundError extends HttpError {
647
647
```typescript
648
648
@Get("/users/:id")
649
649
@OnUndefined(UserNotFoundError)
650
-
saveUser(@PathParam("id") id: number) {
650
+
saveUser(@Param("id") id: number) {
651
651
returnuserRepository.findOneById(id);
652
652
}
653
653
```
@@ -661,7 +661,7 @@ You can set any custom header in a response:
661
661
```typescript
662
662
@Get("/users/:id")
663
663
@Header("Cache-Control", "none")
664
-
getOne(@PathParam("id") id: number) {
664
+
getOne(@Param("id") id: number) {
665
665
// ...
666
666
}
667
667
```
@@ -691,7 +691,7 @@ If you want to return errors with specific error codes, there is an easy way:
691
691
692
692
```typescript
693
693
@Get("/users/:id")
694
-
getOne(@PathParam("id") id: number) {
694
+
getOne(@Param("id") id: number) {
695
695
696
696
const user =this.userRepository.findOneById(id);
697
697
if (!user)
@@ -810,7 +810,7 @@ For example, lets try to use [compression](https://github.com/expressjs/compress
810
810
811
811
@Get("/users/:id")
812
812
@UseBefore(compression())
813
-
getOne(@PathParam("id") id: number) {
813
+
getOne(@Param("id") id: number) {
814
814
// ...
815
815
}
816
816
```
@@ -902,7 +902,7 @@ Here is example of creating middleware for express.js:
902
902
@Get("/users/:id")
903
903
@UseBefore(MyMiddleware)
904
904
@UseAfter(loggingMiddleware)
905
-
getOne(@PathParam("id") id: number) {
905
+
getOne(@Param("id") id: number) {
906
906
// ...
907
907
}
908
908
```
@@ -969,7 +969,7 @@ Here is example of creating middleware for koa.js:
969
969
@Get("/users/:id")
970
970
@UseBefore(MyMiddleware)
971
971
@UseAfter(loggingMiddleware)
972
-
getOne(@PathParam("id") id: number) {
972
+
getOne(@Param("id") id: number) {
973
973
// ...
974
974
}
975
975
```
@@ -1075,7 +1075,7 @@ import {Get, Param, UseInterceptor} from "routing-controllers";
1075
1075
// in it and return a replaced result. replaced result will be returned to the user
1076
1076
returncontent.replace(/Mike/gi, "Michael");
1077
1077
})
1078
-
getOne(@PathParam("id") id: number) {
1078
+
getOne(@Param("id") id: number) {
1079
1079
return"Hello, I am Mike!"; // client will get a "Hello, I am Michael!" response.
1080
1080
}
1081
1081
```
@@ -1109,7 +1109,7 @@ import {NameCorrectionInterceptor} from "./NameCorrectionInterceptor";
1109
1109
1110
1110
@Get("/users")
1111
1111
@UseInterceptor(NameCorrectionInterceptor)
1112
-
getOne(@PathParam("id") id: number) {
1112
+
getOne(@Param("id") id: number) {
1113
1113
return"Hello, I am Mike!"; // client will get a "Hello, I am Michael!" response.
1114
1114
}
1115
1115
```
@@ -1173,7 +1173,7 @@ export class UserController {
1173
1173
If `User` is an interface - then simple literal object will be created.
1174
1174
If its a class - then instance of this class will be created.
1175
1175
1176
-
This technique works not only with `@Body`, but also with `@PathParam`, `@QueryParam`, `@BodyParam` and other decorators.
1176
+
This technique works not only with `@Body`, but also with `@Param`, `@QueryParam`, `@BodyParam` and other decorators.
1177
1177
Learn more about class-transformer and how to handle more complex object constructions [here][4].
1178
1178
This behaviour is enabled by default.
1179
1179
If you want to disable it simply pass `classTransformer: false` to createExpressServer method.
@@ -1234,7 +1234,7 @@ an error will be thrown and captured by routing-controller, so the client will r
1234
1234
1235
1235
If you need special options for validation (groups, skipping missing properties, etc.) or transforming (groups, excluding prefixes, versions, etc.), you can pass them as global config as `validation` in createExpressServer method or as a local `validate` setting for method parameter - `@Body({ validate: localOptions })`.
1236
1236
1237
-
This technique works not only with `@Body` but also with `@PathParam`, `@QueryParam`, `@BodyParam` and other decorators.
1237
+
This technique works not only with `@Body` but also with `@Param`, `@QueryParam`, `@BodyParam` and other decorators.
1238
1238
1239
1239
## Using authorization features
1240
1240
@@ -1428,8 +1428,8 @@ export class QuestionController {
0 commit comments