### Class: bootcomponent = new BootComponent()

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.

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
booters | `(ControllerBooter | RepositoryBooter)[]` | [ControllerBooter, RepositoryBooter] | 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.

#### constructor(app: Application) : BootComponent

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `Application` |  |  | Application instance

### Class: baseartifactbooter = new BaseArtifactBooter()

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

1. Set the 'options' property to a object of ArtifactOptions type. (Each extending class should provide defaults for the ArtifactOptions and use Object.assign to merge the properties with user provided Options).
2. Provide it's own logic for 'load' after calling 'await super.load()' to actually boot the Artifact classes.

Currently supports the following boot phases: configure, discover, load

Properties

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 Set the 'options' property to a object of ArtifactOptions type. (Each extending class should provide defaults for the ArtifactOptions and use Object.assign to merge the properties with user provided Options). Provide it's own logic for 'load' after calling 'await super.load()' to actually boot the Artifact classes. 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 Set the 'options' property to a object of ArtifactOptions type. (Each extending class should provide defaults for the ArtifactOptions and use Object.assign to merge the properties with user provided Options). Provide it's own logic for 'load' after calling 'await super.load()' to actually boot the Artifact classes. 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 Set the 'options' property to a object of ArtifactOptions type. (Each extending class should provide defaults for the ArtifactOptions and use Object.assign to merge the properties with user provided Options). Provide it's own logic for 'load' after calling 'await super.load()' to actually boot the Artifact classes. 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 Set the 'options' property to a object of ArtifactOptions type. (Each extending class should provide defaults for the ArtifactOptions and use Object.assign to merge the properties with user provided Options). Provide it's own logic for 'load' after calling 'await super.load()' to actually boot the Artifact classes. 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 Set the 'options' property to a object of ArtifactOptions type. (Each extending class should provide defaults for the ArtifactOptions and use Object.assign to merge the properties with user provided Options). Provide it's own logic for 'load' after calling 'await super.load()' to actually boot the Artifact classes. 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 Set the 'options' property to a object of ArtifactOptions type. (Each extending class should provide defaults for the ArtifactOptions and use Object.assign to merge the properties with user provided Options). Provide it's own logic for 'load' after calling 'await super.load()' to actually boot the Artifact classes. Currently supports the following boot phases: configure, discover, load

#### configure() : Promise<void>

Configure the Booter by initializing the 'dirs', 'extensions' and 'glob' properties.

NOTE: All properties are configured even if all aren't used.

#### discover() : Promise<void>

Discover files based on the 'glob' property relative to the 'projectRoot'. Discovered artifact files matching the pattern are saved to the 'discovered' property.

#### load() : Promise<void>

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.

### Function: discoverFiles

#### discoverFiles(pattern: string, root: string) : Promise<string[]>

Returns all files matching the given glob pattern relative to root

Returns:

Array of discovered files

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
pattern | `string` |  |  | A glob pattern
root | `string` |  |  | Root folder to start searching for matching files

### Function: isClass

#### isClass(target: any) : boolean

Given a function, returns true if it is a class, false otherwise.

Returns:

True if target is a class. False otherwise.

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
target | `any` |  |  | The function to check if it's a class or not.

### Function: loadClassesFromFiles

#### loadClassesFromFiles(files: string[]) : Constructor<__type>[]

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.

Returns:

> []} An array of Class constructors from a file

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
files | `string[]` |  |  | An array of string of absolute file paths

### Class: controllerbooter = new ControllerBooter()

A class that extends BaseArtifactBooter to boot the 'Controller' artifact type. Discovered controllers are bound using `app.controller()`.

Supported phases: configure, discover, load

Properties

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 `app.controller()`. 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 `app.controller()`. Supported phases: configure, discover, load
projectRoot | `string` |  | constructorProperty exported public | A class that extends BaseArtifactBooter to boot the 'Controller' artifact type. Discovered controllers are bound using `app.controller()`. Supported phases: configure, discover, load

#### constructor(app: Application, projectRoot: string, controllerConfig: ArtifactOptions) : ControllerBooter

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `Application` |  |  | A class that extends BaseArtifactBooter to boot the 'Controller' artifact type. Discovered controllers are bound using `app.controller()`. Supported phases: configure, discover, load
projectRoot | `string` |  |  | A class that extends BaseArtifactBooter to boot the 'Controller' artifact type. Discovered controllers are bound using `app.controller()`. Supported phases: configure, discover, load
controllerConfig | `ArtifactOptions` | {} |  | A class that extends BaseArtifactBooter to boot the 'Controller' artifact type. Discovered controllers are bound using `app.controller()`. Supported phases: configure, discover, load

#### load() : Promise<void>

Uses super method to get a list of Artifact classes. Boot each class by binding it to the application using `app.controller(controller);`.

### Object literal: ControllerDefaults

Default ArtifactOptions for ControllerBooter.

Variables

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dirs | `string[]` | ['controllers'] | exported | Default ArtifactOptions for ControllerBooter.
extensions | `string[]` | ['.controller.js'] | exported | Default ArtifactOptions for ControllerBooter.
nested | `true` | true | exported | Default ArtifactOptions for ControllerBooter.

### Class: repositorybooter = new RepositoryBooter()

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

Properties

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `AppWithRepository` |  | constructorProperty exported public | 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
projectRoot | `string` |  | constructorProperty exported public | 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
repositoryOptions | `ArtifactOptions` |  | constructorProperty exported public | 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

#### constructor(app: AppWithRepository, projectRoot: string, repositoryOptions: ArtifactOptions) : RepositoryBooter

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `AppWithRepository` |  |  | 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
projectRoot | `string` |  |  | 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
repositoryOptions | `ArtifactOptions` | {} |  | 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

#### load() : Promise<void>

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.

### Object literal: RepositoryDefaults

Default ArtifactOptions for RepositoryBooter.

Variables

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
dirs | `string[]` | ['repositories'] | exported | Default ArtifactOptions for RepositoryBooter.
extensions | `string[]` | ['.repository.js'] | exported | Default ArtifactOptions for RepositoryBooter.
nested | `true` | true | exported | Default ArtifactOptions for RepositoryBooter.

### Class: bootstrapper = new Bootstrapper()

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.

#### constructor(app: , projectRoot: string, bootOptions: BootOptions) : Bootstrapper

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
app | `` |  |  | 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.
projectRoot | `string` |  |  | 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.
bootOptions | `BootOptions` | {} |  | 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.

#### boot(execOptions: BootExecutionOptions, ctx: Context) : Promise<Context>

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.

Parameters

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 `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.

### Interface: Bootable

Interface to describe the additions made available to an Application that uses BootMixin.

Properties

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.

#### boot() : Promise<void>

#### booters(booterCls: Constructor<Booter>[]) : Binding[]

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
booterCls | `Constructor<Booter>[]` |  | rest | Interface to describe the additions made available to an Application that uses BootMixin.

### Interface: Booter

Defines the requirements to implement a Booter for LoopBack applications: configure() : Promise discover() : Promise load(): Promise

A Booter will run through the above methods in order.

#### configure() : Promise<void>

Configure phase of the Booter. It should set options / defaults in this phase.

#### discover() : Promise<void>

Discover phase of the Booter. It should search for artifacts in this phase.

#### load() : Promise<void>

Load phase of the Booter. It should bind the artifacts in this phase.

### Type alias: BootExecutionOptions(prop: string): any

Additional Properties

Arguments

Name | Type | Description
--- | --- | ---
prop | `string` |

### Type alias: BootOptions(prop: string): any

Type Object for Options passed into .boot()

Returns:

Arguments

Name | Type | Description
--- | --- | ---
prop | `string` |

### const BOOTER_PHASES = ['configure', 'discover', 'load']

Export of an array of all the Booter phases supported by the interface above, in the order they should be run.

### Namespace: BootBindings

Namespace for core binding keys

### const BootBindings.BOOTER_PREFIX = "booters"

Namespace for core binding keys

### const BootBindings.BOOTER_TAG = "booter"

Namespace for core binding keys

### const BootBindings.BOOTSTRAPPER_KEY = BindingKey.create( 'application.bootstrapper', )

Binding key for binding the BootStrapper class

### const BootBindings.BOOT_OPTIONS = BindingKey.create('boot.options')

Binding key for Boot configuration

### const BootBindings.PROJECT_ROOT = BindingKey.create('boot.project_root')

Binding key for determining project root directory

### Function: BootMixin

#### BootMixin(superClass: T) :

Mixin for @loopback/boot. This Mixin provides the following:

- Implements the Bootable Interface as follows.
- Add a `projectRoot` property to the Class
- Adds an optional `bootOptions` property to the Class that can be used to store the Booter conventions.
- Adds the `BootComponent` to the Class (which binds the Bootstrapper and default Booters)
- Provides the `boot()` convenience method to call Bootstrapper.boot()
- Provides the `booter()` convenience method to bind a Booter(s) to the Application
- Override `component()` to call `mountComponentBooters`
- Adds `mountComponentBooters` 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 **

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
superClass | `T` |  |  |

### Function: _bindBooter

#### _bindBooter(ctx: Context, booterCls: Constructor<Booter>) : Binding

Method which binds a given Booter to a given Context with the Prefix and Tags expected by the Bootstrapper

Parameters

Name | Type | Default Value | Flags | Description
--- | --- | --- | --- | ---
ctx | `Context` |  |  | The Context to bind the Booter Class
booterCls | `Constructor<Booter>` |  |  | Booter class to be bound