The "@inject" decorator uses Reflection to inspect the dependencies of a class or a method and defines them as metadata on the class for the container to discover them.
@inject()class UsersController { constructor(private database: Database) {}} Copy
@inject()class UsersController { constructor(private database: Database) {}}
class UsersController { @inject() async index(request: Request, response: Response) { // Method with dependency injection }} Copy
class UsersController { @inject() async index(request: Request, response: Response) { // Method with dependency injection }}
The "@inject" decorator uses Reflection to inspect the dependencies of a class or a method and defines them as metadata on the class for the container to discover them.