BootComponent is used to export the default list of Booter's made available by this module as well as bind the BootStrapper to the app so it can be used to run the Booters.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| booters |
(ControllerBooter | RepositoryBooter | ServiceBooter | DataSourceBooter)[]
|
[ ControllerBooter, RepositoryBooter, ServiceBooter, DataSourceBooter, ] | exported |
BootComponent is used to export the default list of Booter's made available by this module as well as bind the BootStrapper to the app so it can be used to run the Booters. |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
Application
|
Application instance |
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them.
Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| classes |
Array<Constructor<__type>>
|
exported |
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
|
| dirs |
string[]
|
exported |
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
|
| discovered |
string[]
|
exported |
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
|
| extensions |
string[]
|
exported |
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
|
| glob |
string
|
exported |
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
|
| options |
ArtifactOptions
|
exported |
Options being used by the Booter. |
|
| projectRoot |
string
|
exported |
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| projectRoot |
string
|
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
||
| options |
ArtifactOptions
|
This class serves as a base class for Booters which follow a pattern of configure, discover files in a folder(s) using explicit folder / extensions or a glob pattern and lastly identifying exported classes from such files and performing an action on such files such as binding them. Any Booter extending this base class is expected to
Currently supports the following boot phases: configure, discover, load |
Get the name of the artifact loaded by this booter, e.g. "Controller". Subclasses can override the default logic based on the class name.
Configure the Booter by initializing the 'dirs', 'extensions' and 'glob' properties.
NOTE: All properties are configured even if all aren't used.
Discover files based on the 'glob' property relative to the 'projectRoot'. Discovered artifact files matching the pattern are saved to the 'discovered' property.
Filters the exports of 'discovered' files to only be Classes (in case function / types are exported) as an artifact is a Class. The filtered artifact Classes are saved in the 'classes' property.
NOTE: Booters extending this class should call this method (await super.load()) and then process the artifact classes as appropriate.
Returns all files matching the given glob pattern relative to root
Array of discovered files
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| pattern |
string
|
A glob pattern |
||
| root |
string
|
Root folder to start searching for matching files |
Given a function, returns true if it is a class, false otherwise.
True if target is a class. False otherwise.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| target |
any
|
The function to check if it's a class or not. |
Returns an Array of Classes from given files. Works by requiring the file, identifying the exports from the file by getting the keys of the file and then testing each exported member to see if it's a class or not.
[]} An array of Class constructors from a file
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| files |
string[]
|
An array of string of absolute file paths |
||
| projectRootDir |
string
|
A class that extends BaseArtifactBooter to boot the 'Controller' artifact type.
Discovered controllers are bound using app.controller().
Supported phases: configure, discover, load
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
Application
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'Controller' artifact type.
Discovered controllers are bound using Supported phases: configure, discover, load |
|
| controllerConfig |
ArtifactOptions
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'Controller' artifact type.
Discovered controllers are bound using Supported phases: configure, discover, load |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
Application
|
A class that extends BaseArtifactBooter to boot the 'Controller' artifact type.
Discovered controllers are bound using Supported phases: configure, discover, load |
||
| projectRoot |
string
|
A class that extends BaseArtifactBooter to boot the 'Controller' artifact type.
Discovered controllers are bound using Supported phases: configure, discover, load |
||
| controllerConfig |
ArtifactOptions
|
{} |
A class that extends BaseArtifactBooter to boot the 'Controller' artifact type.
Discovered controllers are bound using Supported phases: configure, discover, load |
Get the name of the artifact loaded by this booter, e.g. "Controller". Subclasses can override the default logic based on the class name.
Uses super method to get a list of Artifact classes. Boot each class by
binding it to the application using app.controller(controller);.
Default ArtifactOptions for ControllerBooter.
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using app.controller().
Supported phases: configure, discover, load
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
ApplicationWithRepositories
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
|
| datasourceConfig |
ArtifactOptions
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
ApplicationWithRepositories
|
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
||
| projectRoot |
string
|
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
||
| datasourceConfig |
ArtifactOptions
|
{} |
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
Get the name of the artifact loaded by this booter, e.g. "Controller". Subclasses can override the default logic based on the class name.
Uses super method to get a list of Artifact classes. Boot each file by creating a DataSourceConstructor and binding it to the application class.
Default ArtifactOptions for DataSourceBooter.
A class that extends BaseArtifactBooter to boot the 'Repository' artifact type.
Discovered repositories are bound using app.repository() which must be added
to an Application using the RepositoryMixin from @loopback/repository.
Supported phases: configure, discover, load
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
ApplicationWithRepositories
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'Repository' artifact type.
Discovered repositories are bound using Supported phases: configure, discover, load |
|
| repositoryOptions |
ArtifactOptions
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'Repository' artifact type.
Discovered repositories are bound using Supported phases: configure, discover, load |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
ApplicationWithRepositories
|
A class that extends BaseArtifactBooter to boot the 'Repository' artifact type.
Discovered repositories are bound using Supported phases: configure, discover, load |
||
| projectRoot |
string
|
A class that extends BaseArtifactBooter to boot the 'Repository' artifact type.
Discovered repositories are bound using Supported phases: configure, discover, load |
||
| repositoryOptions |
ArtifactOptions
|
{} |
A class that extends BaseArtifactBooter to boot the 'Repository' artifact type.
Discovered repositories are bound using Supported phases: configure, discover, load |
Get the name of the artifact loaded by this booter, e.g. "Controller". Subclasses can override the default logic based on the class name.
Uses super method to get a list of Artifact classes. Boot each class by
binding it to the application using app.repository(repository); if present.
Default ArtifactOptions for RepositoryBooter.
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using app.controller().
Supported phases: configure, discover, load
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
ApplicationWithServices
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
|
| serviceConfig |
ArtifactOptions
|
constructorProperty exported public |
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
|
| serviceProviders |
ServiceProviderClass[]
|
exported |
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
ApplicationWithServices
|
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
||
| projectRoot |
string
|
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
||
| serviceConfig |
ArtifactOptions
|
{} |
A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type.
Discovered DataSources are bound using Supported phases: configure, discover, load |
Get the name of the artifact loaded by this booter, e.g. "Controller". Subclasses can override the default logic based on the class name.
Uses super method to get a list of Artifact classes. Boot each file by creating a DataSourceConstructor and binding it to the application class.
Default ArtifactOptions for DataSourceBooter.
The Bootstrapper class provides the boot function that is responsible for
finding and executing the Booters in an application based on given options.
NOTE: Bootstrapper should be bound as a SINGLETON so it can be cached as it does not maintain any state of it's own.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
|
The Bootstrapper class provides the NOTE: Bootstrapper should be bound as a SINGLETON so it can be cached as it does not maintain any state of it's own. |
||
| projectRoot |
string
|
The Bootstrapper class provides the NOTE: Bootstrapper should be bound as a SINGLETON so it can be cached as it does not maintain any state of it's own. |
||
| bootOptions |
BootOptions
|
{} |
The Bootstrapper class provides the NOTE: Bootstrapper should be bound as a SINGLETON so it can be cached as it does not maintain any state of it's own. |
Function is responsible for calling all registered Booter classes that are bound to the Application instance. Each phase of an instance must complete before the next phase is started.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| execOptions |
BootExecutionOptions
|
optional |
Execution options for boot. These determine the phases and booters that are run. |
|
| ctx |
Context
|
optional |
The Bootstrapper class provides the NOTE: Bootstrapper should be bound as a SINGLETON so it can be cached as it does not maintain any state of it's own. |
Interface to describe the additions made available to an Application that uses BootMixin.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| bootOptions |
BootOptions
|
exported optional |
Interface to describe the additions made available to an Application that uses BootMixin. |
|
| projectRoot |
string
|
exported |
Interface to describe the additions made available to an Application that uses BootMixin. |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| booterCls |
Constructor<Booter>[]
|
rest |
Interface to describe the additions made available to an Application that uses BootMixin. |
Defines the requirements to implement a Booter for LoopBack applications:
configure() : Promise
A Booter will run through the above methods in order.
Configure phase of the Booter. It should set options / defaults in this phase.
Discover phase of the Booter. It should search for artifacts in this phase.
Load phase of the Booter. It should bind the artifacts in this phase.
Additional Properties
| Name | Type | Description |
|---|---|---|
| prop |
string
|
Type Object for Options passed into .boot()
Returns:| Name | Type | Description |
|---|---|---|
| prop |
string
|
|
Export of an array of all the Booter phases supported by the interface above, in the order they should be run.
Namespace for core binding keys
Namespace for core binding keys
Namespace for core binding keys
Binding key for binding the BootStrapper class
Binding key for Boot configuration
Binding key for determining project root directory
Mixin for @loopback/boot. This Mixin provides the following:
projectRoot property to the ClassbootOptions property to the Class that can be used to
store the Booter conventions.BootComponent to the Class (which binds the Bootstrapper and default Booters)boot() convenience method to call Bootstrapper.boot()booter() convenience method to bind a Booter(s) to the Applicationcomponent() to call mountComponentBootersmountComponentBooters which binds Booters to the application from component.booters[]**** NOTE **** Trying to constrain the type of this Mixin (or any Mixin) will cause errors. For example, constraining this Mixin to type Application require all types using by Application to be imported (including it's dependencies such as ResolutionSession). Another issue was that if a Mixin that is type constrained is used with another Mixin that is not, it will result in an error. Example (class MyApp extends BootMixin(RepositoryMixin(Application))) {}; **** END OF NOTE ****
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| superClass |
T
|
Method which binds a given Booter to a given Context with the Prefix and Tags expected by the Bootstrapper
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| ctx |
Context
|
The Context to bind the Booter Class |
||
| booterCls |
Constructor<Booter>
|
Booter class to be bound |