Constructor
new MiddlewareUnit(base_directoryopt, globals_fileopt)
Instantiate the unit.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
base_directory |
string |
<optional> |
'./app/routing/middleware' | |
globals_file |
string |
<optional> |
'./app/routing/Middleware.js' |
Extends
Members
(static) name
Get the name of the service provided by this unit: 'middlewares'
(static) services
Defines the services required by this unit.
(private) _di_allow_defer :boolean
If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.
- boolean
- Source:
(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>
Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.
- Source:
(private) _di_deferred_services :Array.<string>
List of services that were deferred and not provided at the time of injection.
- Array.<string>
- Source:
canonical_item :string
The canonical name of the item.
- string
canonical_items :object
Mapping of canonical names to instances for this item.
- object
- Source:
directory :Promise.<void>|Promise.<string>
The root directory for this canonical resource's files.
- Promise.<void> | Promise.<string>
- Source:
globals_file :Promise.<void>|Promise.<string>
Fully-qualified path to the file with the definitions for globally-applied middleware.
- Promise.<void> | Promise.<string>
suffix :string
The file extension of the canonical item files.
- string
Methods
(async) cleanup(app) → {Promise.<void>}
Cleans up the unit's resources before Flitter closes.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the Flitter app |
- Source:
- Type
- Promise.<void>
directories() → {Object}
Get the directories provided by this unit. module:libflitter/middleware/MiddlewareUnit~MiddlewareUnit#directory as "middleware".
- Type
- Object
get(name, args) → {function}
A helper function to return the Express middleware function for a registered middleware, using its Flitter canonical name.
Name | Type | Description |
---|---|---|
name |
string | the Flitter canonical name of the middleware whose handler should be returned |
args |
* | An argument or arguments to be passed to the middleware function as the 4th argument. |
- the Express middleware
- Type
- function
(async) go(app) → {Promise.<void>}
Initializes the unit. Registers global middleware.
Name | Type | Description |
---|---|---|
app |
module:libflitter/app/FlitterApp~FlitterApp | the Flitter app |
- Type
- Promise.<void>
(async) init_canonical_file(info) → {Promise.<*>}
Prepare a single canonical middleware definition and return the value that should be given by the resolver.
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
info |
object |
Properties
|
- Type
- Promise.<*>
migrations() → {string}
Get the fully-qualified path to the migrations provided by this unit.
- Type
- string
name() → {String}
Get the name of the unit. Should be a lowercase, alphanum/dash/underscore string.
- Source:
- Type
- String
status(setopt) → {string}
Get or set the unit's current status.
Name | Type | Attributes | Description |
---|---|---|---|
set |
string |
<optional> |
if provided, set the status of the unit |
- Source:
- current status of the unit
- Type
- string
templates() → {Object}
Get the templates provided by this unit. Currently, "middleware" template, using the generator module:libflitter/templates/middleware.
- Type
- Object