The Routing Unit
Loads the route definition files from the specified and creates Express routers for each file, then registers them with the underlying Express app. Creates a global function to return a redirect response.
constructor(String router_directory = './app/routing/routers')
Initializes the class. Resolves the fully-qualified path of the
router_directory and stores it in
go(express app, function next)
Creates an alias function to make returning redirections easier. Then, it reads the files in
this.directory, non-recursively and loads the routes defined in each valid file. Using these routes, it creates an Express router for each file and registers it with the underlying Express
app. This establishes the
Routing context and calls the
next function in the stack under it.
Object describing the services, templates, and directories provided by this unit. They are as follows:
||The name of the service. This is added to the
||The fully-qualified path of the router files. This is added to the
||Template that creates new config file in
Set on initialization. Specifies the fully-qualified path of the route definition files to be processed. Each of these files should export an
Object of key-value pairs that hold the route definition information for that file. Each file's configuration is assigned a name based on the name of the file it was retrieved from. Unlike other units, this does not include sub-directories. Only files in the top-level folder are parsed.
Loads the routes from the definition files in the specified directory and makes them available to the underlying Express app. Guarantees that the routes have been registered and are present in the
_flit.routing.routes object. Also provides utility functions.
Holds the variables and functions provided by this unit.
Set of key-value pairs such that the key is the name of the route definition file parsed from the top-level directory only, and the value is the
Object of route definition information from that file.
Returns a handler function that will send a response redirecting the user to the given
destination URL. Meant to be used in the route definition files, like so:
// creates a handler function for Flitter that sends a redirect to 'http(s)://app.url/dashboard' '/dash': [ redirect('/dashboard') ]