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
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,13 @@
1
1
# Changelog and release notes
2
2
3
+
### 0.8.0
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)
7
+
- normalize param object properties (for "queries", "headers", "params" and "cookies") - now you can easily validate query/path params using `class-validator` (#289)
8
+
- enhance params normalization - converting from string to primitive types is now more strict and can throw ParamNormalizationError,
9
+
e.g. when number is expected but the invalid string (NaN) has been received (#289)
10
+
3
11
### 0.7.2
4
12
5
13
- FIXED: Using `@Authorization` decorator with Koa caused 404 responses (ref [#240](https://github.com/pleerock/routing-controllers/pull/240))
@@ -596,7 +627,7 @@ This action will return 404 in the case if user was not found, and regular 200 i
596
627
```typescript
597
628
@Get("/users/:id")
598
629
@OnUndefined(404)
599
-
getOne(@Param("id") id: number) {
630
+
getOne(@PathParam("id") id: number) {
600
631
returnuserRepository.findOneById(id);
601
632
}
602
633
```
@@ -616,7 +647,7 @@ export class UserNotFoundError extends HttpError {
616
647
```typescript
617
648
@Get("/users/:id")
618
649
@OnUndefined(UserNotFoundError)
619
-
saveUser(@Param("id") id: number) {
650
+
saveUser(@PathParam("id") id: number) {
620
651
returnuserRepository.findOneById(id);
621
652
}
622
653
```
@@ -630,7 +661,7 @@ You can set any custom header in a response:
630
661
```typescript
631
662
@Get("/users/:id")
632
663
@Header("Cache-Control", "none")
633
-
getOne(@Param("id") id: number) {
664
+
getOne(@PathParam("id") id: number) {
634
665
// ...
635
666
}
636
667
```
@@ -660,7 +691,7 @@ If you want to return errors with specific error codes, there is an easy way:
660
691
661
692
```typescript
662
693
@Get("/users/:id")
663
-
getOne(@Param("id") id: number) {
694
+
getOne(@PathParam("id") id: number) {
664
695
665
696
const user =this.userRepository.findOneById(id);
666
697
if (!user)
@@ -779,7 +810,7 @@ For example, lets try to use [compression](https://github.com/expressjs/compress
779
810
780
811
@Get("/users/:id")
781
812
@UseBefore(compression())
782
-
getOne(@Param("id") id: number) {
813
+
getOne(@PathParam("id") id: number) {
783
814
// ...
784
815
}
785
816
```
@@ -871,7 +902,7 @@ Here is example of creating middleware for express.js:
871
902
@Get("/users/:id")
872
903
@UseBefore(MyMiddleware)
873
904
@UseAfter(loggingMiddleware)
874
-
getOne(@Param("id") id: number) {
905
+
getOne(@PathParam("id") id: number) {
875
906
// ...
876
907
}
877
908
```
@@ -938,7 +969,7 @@ Here is example of creating middleware for koa.js:
938
969
@Get("/users/:id")
939
970
@UseBefore(MyMiddleware)
940
971
@UseAfter(loggingMiddleware)
941
-
getOne(@Param("id") id: number) {
972
+
getOne(@PathParam("id") id: number) {
942
973
// ...
943
974
}
944
975
```
@@ -1044,7 +1075,7 @@ import {Get, Param, UseInterceptor} from "routing-controllers";
1044
1075
// in it and return a replaced result. replaced result will be returned to the user
1045
1076
returncontent.replace(/Mike/gi, "Michael");
1046
1077
})
1047
-
getOne(@Param("id") id: number) {
1078
+
getOne(@PathParam("id") id: number) {
1048
1079
return"Hello, I am Mike!"; // client will get a "Hello, I am Michael!" response.
1049
1080
}
1050
1081
```
@@ -1078,7 +1109,7 @@ import {NameCorrectionInterceptor} from "./NameCorrectionInterceptor";
1078
1109
1079
1110
@Get("/users")
1080
1111
@UseInterceptor(NameCorrectionInterceptor)
1081
-
getOne(@Param("id") id: number) {
1112
+
getOne(@PathParam("id") id: number) {
1082
1113
return"Hello, I am Mike!"; // client will get a "Hello, I am Michael!" response.
1083
1114
}
1084
1115
```
@@ -1142,7 +1173,7 @@ export class UserController {
1142
1173
If `User` is an interface - then simple literal object will be created.
1143
1174
If its a class - then instance of this class will be created.
1144
1175
1145
-
This technique works not only with `@Body`, but also with `@Param`, `@QueryParam`, `@BodyParam` and other decorators.
1176
+
This technique works not only with `@Body`, but also with `@PathParam`, `@QueryParam`, `@BodyParam` and other decorators.
1146
1177
Learn more about class-transformer and how to handle more complex object constructions [here][4].
1147
1178
This behaviour is enabled by default.
1148
1179
If you want to disable it simply pass `classTransformer: false` to createExpressServer method.
@@ -1203,7 +1234,7 @@ an error will be thrown and captured by routing-controller, so the client will r
1203
1234
1204
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 })`.
1205
1236
1206
-
This technique works not only with `@Body` but also with `@Param`, `@QueryParam`, `@BodyParam` and other decorators.
1237
+
This technique works not only with `@Body` but also with `@PathParam`, `@QueryParam`, `@BodyParam` and other decorators.
1207
1238
1208
1239
## Using authorization features
1209
1240
@@ -1397,8 +1428,8 @@ export class QuestionController {
0 commit comments