The InversifyJS Express utils allow us to declare controllers using what is known as declarative routing. Instead of declaring Router instances, we can annotate a controller class using some decorators. The metadata generated by the decorators is later used by the InversifyJS express utils to generate the Router instances for us.
The following example uses the following decorators:
- @controller(path): It is used to declare the path of a router
- @inject(type): It is used to inject dependencies into a class
- @httpGet(subpath): It is used to declare a route handler for HTTP GET requests
- @httpPost(subpath): It is used to declare a route handler for HTTP POST requests
- @response(): It is used to pass the response object to a route handler ...