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
You can use `@UseInterceptor` per-action, or per-controller.
1155
1155
If its used per-controller then interceptor will apply to all controller actions.
1156
1156
1157
+
### Generic Action Interface
1158
+
1159
+
You can now use generics with the `Action` interface to specify types for the request, response, context, and next function. This allows for better type safety and intellisense when working with different frameworks or custom types. Here's an example:
// You can now use action.request and action.response with proper typing
1175
+
console.log(action.request.headers);
1176
+
action.response.status(201);
1177
+
}
1178
+
}
1179
+
```
1180
+
1181
+
The `Action` interface now accepts four generic parameters:
1182
+
1183
+
1.`TRequest`: The type of the request object (default: `any`)
1184
+
2.`TResponse`: The type of the response object (default: `any`)
1185
+
3.`TContext`: The type of the context object (for Koa-specific usage, default: `any`)
1186
+
4.`TNext`: The type of the next function (default: `Function`)
1187
+
1188
+
This change allows for more flexibility and type safety when working with different frameworks or custom request/response types in your routing-controllers applications.
1189
+
1157
1190
### Interceptor classes
1158
1191
1159
1192
You can also create a class and use it with `@UseInterceptor` decorator:
0 commit comments