Elf Routing is the routing solution for the Elf- suite. It provides utilities that make routing a TypeORM + Express app a breeze.
The
RegisterRoutes
initializes the configured routes. The parameters are described below:
app
: The express appresolveController?
: If you use Dependency Injection, provide a means to resolve a controller. If this is left undefined, a new instance of every controller is created every time it's needed.controllers?
: A path to the controllers folder. Default value issrc/controller
generatePermissionsFile?
: Generate a permissions file from methods that have thecheckPermissions
flag set totrue
via the Elf Authentication library. The permissions are written to aelf.permissions.ts
file in the root folder.
The following decorators are provided
Decorating a class with
@Controller()
makes it a controller. The name parameter specifies the route to be assigned to the controller.
Decorate a method within a controller class with this decorator to make it respond to POST requests. Use the match variable to specify a match pattern.
Decorate a method within a controller class with this decorator to make it respond to GET requests. Use the match variable to specify a match pattern.
Decorate a method within a controller class with this decorator to make it respond to PUT requests. Use the match variable to specify a match pattern.
Decorate a method within a controller class with this decorator to make it respond to PATCH requests. Use the match variable to specify a match pattern.
Decorate a method within a controller class with this decorator to make it respond to DELETE requests. Use the match variable to specify a match pattern.