@loopback/docs
Version:
Documentation for LoopBack 4
74 lines (55 loc) • 7.22 kB
Markdown
---
lang: en
title: 'API docs: boot'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.boot.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/boot](./boot.md)
## boot package
[@loopback/boot](https://github.com/strongloop/loopback-next/tree/master/packages/boot)
## Classes
| Class | Description |
| --- | --- |
| [ApplicationMetadataBooter](./boot.applicationmetadatabooter.md) | Configure the application with metadata from <code>package.json</code> |
| [BaseArtifactBooter](./boot.baseartifactbooter.md) | 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. |
| [BootComponent](./boot.bootcomponent.md) | 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. |
| [Bootstrapper](./boot.bootstrapper.md) | The Bootstrapper class provides the <code>boot</code> 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. |
| [ControllerBooter](./boot.controllerbooter.md) | A class that extends BaseArtifactBooter to boot the 'Controller' artifact type. Discovered controllers are bound using <code>app.controller()</code>.<!-- -->Supported phases: configure, discover, load |
| [DataSourceBooter](./boot.datasourcebooter.md) | A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type. Discovered DataSources are bound using <code>app.controller()</code>.<!-- -->Supported phases: configure, discover, load |
| [LifeCycleObserverBooter](./boot.lifecycleobserverbooter.md) | A class that extends BaseArtifactBooter to boot the 'LifeCycleObserver' artifact type.<!-- -->Supported phases: configure, discover, load |
| [RepositoryBooter](./boot.repositorybooter.md) | A class that extends BaseArtifactBooter to boot the 'Repository' artifact type. Discovered repositories are bound using <code>app.repository()</code> which must be added to an Application using the <code>RepositoryMixin</code> from <code>@loopback/repository</code>.<!-- -->Supported phases: configure, discover, load |
| [ServiceBooter](./boot.servicebooter.md) | A class that extends BaseArtifactBooter to boot the 'Service' artifact type. Discovered DataSources are bound using <code>app.controller()</code>.<!-- -->Supported phases: configure, discover, load |
## Functions
| Function | Description |
| --- | --- |
| [\_bindBooter(ctx, booterCls)](./boot._bindbooter.md) | Method which binds a given Booter to a given Context with the Prefix and Tags expected by the Bootstrapper |
| [BootMixin(superClass)](./boot.bootmixin.md) | Mixin for @<!-- -->loopback/boot. This Mixin provides the following: - Implements the Bootable Interface as follows. - Add a <code>projectRoot</code> property to the Class - Adds an optional <code>bootOptions</code> property to the Class that can be used to store the Booter conventions. - Adds the <code>BootComponent</code> to the Class (which binds the Bootstrapper and default Booters) - Provides the <code>boot()</code> convenience method to call Bootstrapper.boot() - Provides the <code>booter()</code> convenience method to bind a Booter(s) to the Application - Override <code>component()</code> to call <code>mountComponentBooters</code> - Adds <code>mountComponentBooters</code> which binds Booters to the application from <code>component.booters[]</code>\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* 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 \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* |
| [discoverFiles(pattern, root)](./boot.discoverfiles.md) | Returns all files matching the given glob pattern relative to root |
| [isClass(target)](./boot.isclass.md) | Given a function, returns true if it is a class, false otherwise. |
| [loadClassesFromFiles(files, projectRootDir)](./boot.loadclassesfromfiles.md) | 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. |
## Interfaces
| Interface | Description |
| --- | --- |
| [Bootable](./boot.bootable.md) | Interface to describe the additions made available to an Application that uses BootMixin. |
| [Booter](./boot.booter.md) | Defines the requirements to implement a Booter for LoopBack applications: - configure() - discover() - load()<!-- -->A Booter will run through the above methods in order. |
## Namespaces
| Namespace | Description |
| --- | --- |
| [BootBindings](./boot.bootbindings.md) | Namespace for core binding keys |
## Variables
| Variable | Description |
| --- | --- |
| [BOOTER\_PHASES](./boot.booter_phases.md) | Export of an array of all the Booter phases supported by the interface above, in the order they should be run. |
| [ControllerDefaults](./boot.controllerdefaults.md) | Default ArtifactOptions for ControllerBooter. |
| [DataSourceDefaults](./boot.datasourcedefaults.md) | Default ArtifactOptions for DataSourceBooter. |
| [LifeCycleObserverDefaults](./boot.lifecycleobserverdefaults.md) | Default ArtifactOptions for DataSourceBooter. |
| [RepositoryDefaults](./boot.repositorydefaults.md) | Default ArtifactOptions for RepositoryBooter. |
| [ServiceDefaults](./boot.servicedefaults.md) | Default ArtifactOptions for DataSourceBooter. |
## Type Aliases
| Type Alias | Description |
| --- | --- |
| [ArtifactOptions](./boot.artifactoptions.md) | Type definition for ArtifactOptions. These are the options supported by this Booter. |
| [BootExecutionOptions](./boot.bootexecutionoptions.md) | Options for boot() execution |
| [BootOptions](./boot.bootoptions.md) | Options to configure <code>Bootstrapper</code> |