README
Elf Routing
Elf Routing is the routing solution for the Elf- suite. It provides utilities that make routing a TypeORM + Express app a breeze.
Methods
RegisterRoutes(app, resolveController, controllers, generatePermissionsFile)
The
RegisterRoutesinitializes 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/controllergeneratePermissionsFile?: Generate a permissions file from methods that have thecheckPermissionsflag set totruevia the Elf Authentication library. The permissions are written to aelf.permissions.tsfile in the root folder.
Decorators
The following decorators are provided
@Controller(name)
Decorating a class with
@Controller()makes it a controller. The name parameter specifies the route to be assigned to the controller.
@HttpPost(match)
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.
@HttpGet(match)
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.
@HttpPut(match)
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.
@HttpPatch(match)
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.
@HttpDelete(match)
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.