Extract the query parameters from the request path.
Parse the request payload.
Register all primary dependences
Configuration
Router
Create all primary dependency instances
Register all middleware defined in the config files to the router depenency instance.
Register all providers defined in the config files.
Boot all providers defined in the config files.
Resolve the request.
Run all global middleware.
Find the route that matches with the request path.
Run all middleware groups associated with the route.
Run all lone middleware associated with the route.
If any middleware resolves, return the result as response; else, return the resolved route action as response.
Middleware
Middleware can be functions or classes that extend the core/Middleware class.
As a function, when called, 2 arguments will be passed.
The request
The next callback
As a class, the will be an invoke method which will be called when the middleware is encounted; and the arguments described above will be passed to said function.
All middleware are defined in the config/app.js file.
There are 3 types of middleware
Global middleware – runs everytime a request is made.
Grouped middleware – contains a set of middleware which run only if assigned to a matching route.
Lone middleware – runs only if assigned to a matching route.
Group and Lone middleware are defined as key-middleware pairs.
Middleware can be assigned to routes by using their definition keys.
Routes
Routes are used to identify what logic to run given some method and path.
All active routes must be register to the router in order to work.
To register a route, you'll need to specify the following.
path - A string that will be coverted to the regex for request resolution.
methods - An array of methods to be compared to during resolution.
action - A function that will be run to finalize the resolution.
middleware (optional) - An array of middleware that are run before the action during resolution.
name (optional) - A tag to reference the route by.
Route parameters can be described in the routes path during registration and definition.
Bindings – functions that transform route parameter values – can also be registered to each route.