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
To disable `class-transformer` on a per-controller or per-route basis, use the `transformRequest` and `transformResponse` options on your controller and route decorators:
You can use any existing express / koa middleware, or create your own.
@@ -1216,7 +1241,34 @@ If its a class - then instance of this class will be created.
1216
1241
This technique works with `@Body`, `@Param`, `@QueryParam`, `@BodyParam`, and other decorators.
1217
1242
Learn more about class-transformer and how to handle more complex object constructions [here][4].
1218
1243
This behaviour is enabled by default.
1219
-
If you want to disable it simply pass `classTransformer: false` to createExpressServer method.
1244
+
If you want to disable it simply pass `classTransformer: false` to createExpressServer method. Alternatively you can disable transforming for [individual controllers or routes](#selectively-disable-requestresponse-transforming).
1245
+
1246
+
## Controller Inheritance
1247
+
Often your application may need to have an option to inherit controller from another to reuse code and void duplication.
1248
+
A good example of the use is the CRUD operations which can be hidden inside `AbstractBaseController` with the possibility to add new and overload methods, the template method pattern.
@@ -1270,7 +1322,7 @@ export class UserController {
1270
1322
}
1271
1323
```
1272
1324
If the param doesn't satisfy the requirements defined by class-validator decorators,
1273
-
an error will be thrown and captured by routing-controllers, so the client will receive 400 Bad Request and JSON with nice detailed [Validation errors](https://github.com/pleerock/class-validator#validation-errors) array.
1325
+
an error will be thrown and captured by routing-controller, so the client will receive 400 Bad Request and JSON with nice detailed [Validation errors](https://github.com/typestack/class-validator#validation-errors) array.
1274
1326
1275
1327
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 })`.
1276
1328
@@ -1371,7 +1423,7 @@ If you mark `@CurrentUser` as `required` and currentUserChecker logic will retur
1371
1423
1372
1424
`routing-controllers` supports a DI container out of the box. You can inject your services into your controllers,
1373
1425
middlewares and error handlers. Container must be setup during application bootstrap.
1374
-
Here is example how to integrate routing-controllers with [typedi](https://github.com/pleerock/typedi):
1426
+
Here is example how to integrate routing-controllers with [typedi](https://github.com/typestack/typedi):
1375
1427
1376
1428
```typescript
1377
1429
import"reflect-metadata";
@@ -1492,7 +1544,8 @@ export class QuestionController {
1492
1544
|`@Patch(route: string\|RegExp)`|`@Patch("/users/:id") patch()`| Methods marked with this decorator will register a request made with PATCH HTTP Method to a given route. In action options you can specify if action should response json or regular text response. |`app.patch("/users/:id", patch)`|
1493
1545
|`@Delete(route: string\|RegExp)`|`@Delete("/users/:id") delete()`| Methods marked with this decorator will register a request made with DELETE HTTP Method to a given route. In action options you can specify if action should response json or regular text response. |`app.delete("/users/:id", delete)`|
1494
1546
|`@Head(route: string\|RegExp)`|`@Head("/users/:id") head()`| Methods marked with this decorator will register a request made with HEAD HTTP Method to a given route. In action options you can specify if action should response json or regular text response. |`app.head("/users/:id", head)`|
1495
-
|`@Method(methodName: string, route: string\|RegExp)`|`@Method("move", "/users/:id") move()`| Methods marked with this decorator will register a request made with given `methodName` HTTP Method to a given route. In action options you can specify if action should response json or regular text response. |`app.move("/users/:id", move)`|
1547
+
|`@All(route: string\|RegExp)`|`@All("/users/me") rewrite()`| Methods marked with this decorator will register a request made with any HTTP Method to a given route. In action options you can specify if action should response json or regular text response. |`app.all("/users/me", rewrite)`|
1548
+
|`@Method(methodName: string, route: string\|RegExp)`|`@Method("move", "/users/:id") move()`| Methods marked with this decorator will register a request made with given `methodName` HTTP Method to a given route. In action options you can specify if action should response json or regular text response. |`app.move("/users/:id", move)`|
1496
1549
1497
1550
#### Method Parameter Decorators
1498
1551
@@ -1531,7 +1584,7 @@ export class QuestionController {
|`@Authorized(roles?: string\|string[])`|`@Authorized("SUPER_ADMIN")` get() | Checks if user is authorized and has given roles on a given route. `currentUserChecker` should be defined in routing-controllers options. ||
1587
+
|`@Authorized(roles?: string\|string[])`|`@Authorized("SUPER_ADMIN")` get() | Checks if user is authorized and has given roles on a given route. `authorizationChecker` should be defined in routing-controllers options. ||
1535
1588
|`@CurrentUser(options?: { required?: boolean })`| get(@CurrentUser({ required: true }) user: User) | Injects currently authorized user. `currentUserChecker` should be defined in routing-controllers options. |
1536
1589
|`@Header(headerName: string, headerValue: string)`|`@Header("Cache-Control", "private")` get() | Allows to explicitly set any HTTP header returned in the response. |
1537
1590
|`@ContentType(contentType: string)`|`@ContentType("text/csv")` get() | Allows to explicitly set HTTP Content-Type returned in the response. |
@@ -1545,11 +1598,11 @@ export class QuestionController {
1545
1598
1546
1599
## Samples
1547
1600
1548
-
* Take a look on [routing-controllers with express](https://github.com/pleerock/routing-controllers-express-demo) which is using routing-controllers.
1549
-
* Take a look on [routing-controllers with koa](https://github.com/pleerock/routing-controllers-koa-demo) which is using routing-controllers.
1550
-
* Take a look on [routing-controllers with angular 2](https://github.com/pleerock/routing-controllers-angular2-demo) which is using routing-controllers.
1601
+
* Take a look on [routing-controllers with express](https://github.com/typestack/routing-controllers-express-demo) which is using routing-controllers.
1602
+
* Take a look on [routing-controllers with koa](https://github.com/typestack/routing-controllers-koa-demo) which is using routing-controllers.
1603
+
* Take a look on [routing-controllers with angular 2](https://github.com/typestack/routing-controllers-angular2-demo) which is using routing-controllers.
1551
1604
* Take a look on [node-microservice-demo](https://github.com/swimlane/node-microservice-demo) which is using routing-controllers.
1552
-
* Take a look on samples in [./sample](https://github.com/pleerock/routing-controllers/tree/master/sample) for more examples
1605
+
* Take a look on samples in [./sample](https://github.com/typestack/routing-controllers/tree/master/sample) for more examples
1553
1606
of usage.
1554
1607
1555
1608
## Release notes
@@ -1559,9 +1612,9 @@ See information about breaking changes and release notes [here](CHANGELOG.md).
0 commit comments