# registerController Function
Module | import { registerController } from "@tsed/di" |
---|---|
Source | /packages/di/src/registries/ProviderRegistry.ts |
# Overview
const registerController: (provider: any, instance?: any) => void;
# Description
Add a new controller in the ProviderRegistry
. This controller will be built when InjectorService
will be loaded.
# Example
import {registerController, InjectorService} from "@tsed/common";
export default class MyController {
constructor(){}
transform() {
return "test";
}
}
registerController({provide: MyController});
// or
registerController(MyController);
const injector = new InjectorService();
injector.load();
const myController = injector.get<MyController>(MyController);
myController.getFoo(); // test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
- 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