# registerInterceptor Function
Module | import { registerInterceptor } from "@tsed/di" |
---|---|
Source | /packages/di/src/registries/ProviderRegistry.ts |
# Overview
const registerInterceptor: (provider: any, instance?: any) => void;
# Description
Add a new interceptor in the ProviderRegistry
. This interceptor will be built when InjectorService
will be loaded.
# Example
import {registerInterceptor, InjectorService} from "@tsed/common";
export default class MyInterceptor {
intercept() {
return "test";
}
}
registerInterceptor({provide: MyInterceptor});
// or
registerInterceptor(MyInterceptor);
const injector = new InjectorService()
injector.load();
const myInterceptor = injector.get<MyInterceptor>(MyInterceptor);
myInterceptor.intercept(); // test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing