@loopback/boot

  • Version 5.0.0
  • Published
  • 224 kB
  • 8 dependencies
  • MIT license

Install

npm i @loopback/boot
yarn add @loopback/boot
pnpm add @loopback/boot

Overview

A convention based project Bootstrapper and Booters for LoopBack Applications.

Remarks

A Booter is a class that can be bound to an Application and is called to perform a task before the Application is started. A Booter may have multiple phases to complete its task. The task for a convention based Booter is to discover and bind Artifacts (Controllers, Repositories, Models, etc.).

An example task of a Booter may be to discover and bind all artifacts of a given type.

A Bootstrapper is needed to manage the Booters and execute them. This is provided in this package. For ease of use, everything needed is packages using a BootMixin. This Mixin will add convenience methods such as boot and booter, as well as properties needed for Bootstrapper such as projectRoot. The Mixin also adds the BootComponent to your Application which binds the Bootstrapper and default Booters made available by this package.

Index

Variables

variable bindingKeysExcludedFromSubApp

const bindingKeysExcludedFromSubApp: string[];
  • Binding keys excluded from a sub application. These bindings booted from the sub application won't be added to the main application.

variable BOOTER_PHASES

const BOOTER_PHASES: string[];
  • Export of an array of all the Booter phases supported by the interface above, in the order they should be run.

variable ControllerDefaults

const ControllerDefaults: ArtifactOptions;
  • Default ArtifactOptions for ControllerBooter.

variable DataSourceDefaults

const DataSourceDefaults: ArtifactOptions;
  • Default ArtifactOptions for DataSourceBooter.

variable InterceptorProviderDefaults

const InterceptorProviderDefaults: ArtifactOptions;
  • Default ArtifactOptions for InterceptorProviderBooter.

variable LifeCycleObserverDefaults

const LifeCycleObserverDefaults: ArtifactOptions;
  • Default ArtifactOptions for DataSourceBooter.

variable ModelDefaults

const ModelDefaults: ArtifactOptions;
  • Default ArtifactOptions for DataSourceBooter.

variable RepositoryDefaults

const RepositoryDefaults: ArtifactOptions;
  • Default ArtifactOptions for RepositoryBooter.

variable RestDefaults

const RestDefaults: ArtifactOptions;
  • Default ArtifactOptions for ControllerBooter.

variable ServiceDefaults

const ServiceDefaults: ArtifactOptions;
  • Default ArtifactOptions for DataSourceBooter.

Functions

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

    Parameter ctx

    The Context to bind the Booter Class

    Parameter booterCls

    Booter class to be bound

function booter

booter: (artifactNamespace: string, ...specs: BindingSpec[]) => ClassDecorator;
  • @booter decorator to mark a class as a Booter and specify the artifact namespace for the configuration of the booter

    Parameter artifactNamespace

    Namespace for the artifact. It will be used to inject configuration from boot options. For example, the Booter class decorated with @booter('controllers') can receive its configuration via @config() from the controllers property of boot options.

    Parameter specs

    Extra specs for the binding

    Example 1

    @booter('controllers')
    export class ControllerBooter extends BaseArtifactBooter {
    constructor(
    @inject(CoreBindings.APPLICATION_INSTANCE) public app: Application,
    @inject(BootBindings.PROJECT_ROOT) projectRoot: string,
    @config()
    public controllerConfig: ArtifactOptions = {},
    ) {
    // ...
    }
    }

function BootMixin

BootMixin: <T extends MixinTarget<Application>>(
superClass: T
) => (new (...args: any[]) => {
projectRoot: string;
bootOptions?: BootOptions | undefined;
booted: boolean;
start(): Promise<void>;
boot(): Promise<void>;
booters(...booterCls: Constructor<Booter>[]): Binding[];
applicationBooter(
subApp: Application & Bootable,
filter?: BindingFilter | undefined
): Binding<Booter>;
component<C extends Component = Component>(
componentCtor: Constructor<C>,
nameOrOptions?: string | BindingFromClassOptions | undefined
): Binding<C>;
mountComponentBooters(
componentInstanceOrClass: Constructor<unknown> | InstanceWithBooters
): void;
readonly options: loopbackContext.ApplicationConfig;
readonly state: string;
controller: <T_1>(
controllerCtor: loopbackContext.ControllerClass<T_1>,
nameOrOptions?: string | BindingFromClassOptions | undefined
) => Binding<T_1>;
server: <T_2 extends loopbackContext.Server>(
ctor: Constructor<T_2>,
nameOrOptions?: string | BindingFromClassOptions | undefined
) => Binding<T_2>;
servers: <T_3 extends loopbackContext.Server>(
ctors: Constructor<T_3>[]
) => Binding<any>[];
getServer: <T_4 extends loopbackContext.Server>(target: any) => Promise<T_4>;
init: () => Promise<void>;
onInit: (
fn: () => loopbackContext.ValueOrPromise<void>
) => Binding<loopbackContext.LifeCycleObserver>;
onStart: (
fn: () => loopbackContext.ValueOrPromise<void>
) => Binding<loopbackContext.LifeCycleObserver>;
stop: () => Promise<void>;
onStop: (
fn: () => loopbackContext.ValueOrPromise<void>
) => Binding<loopbackContext.LifeCycleObserver>;
setMetadata: (metadata: loopbackContext.ApplicationMetadata) => void;
lifeCycleObserver: <T_5 extends loopbackContext.LifeCycleObserver>(
ctor: Constructor<T_5>,
nameOrOptions?: string | BindingFromClassOptions | undefined
) => Binding<T_5>;
service: <S>(
cls: loopbackContext.ServiceOrProviderClass<S>,
nameOrOptions?: string | loopbackContext.ServiceOptions | undefined
) => Binding<S>;
interceptor: (
interceptor:
| loopbackContext.Interceptor
| Constructor<loopbackContext.Provider<loopbackContext.Interceptor>>,
nameOrOptions?:
| string
| loopbackContext.InterceptorBindingOptions
| undefined
) => Binding<loopbackContext.Interceptor>;
readonly name: string;
readonly subscriptionManager: loopbackContext.ContextSubscriptionManager;
scope: BindingScope;
readonly parent: Context | undefined;
emitEvent: <T_6 extends loopbackContext.ContextEvent>(
type: string,
event: T_6
) => void;
emitError: (err: unknown) => void;
bind: <ValueType = any>(
key: loopbackContext.BindingAddress<ValueType>
) => Binding<ValueType>;
add: (binding: Binding<unknown>) => Application;
configure: <ConfigValueType = any>(
key?: loopbackContext.BindingAddress<unknown> | undefined
) => Binding<ConfigValueType>;
getConfigAsValueOrPromise: <ConfigValueType_1>(
key: loopbackContext.BindingAddress<unknown>,
propertyPath?: string | undefined,
resolutionOptions?: loopbackContext.ResolutionOptions | undefined
) => loopbackContext.ValueOrPromise<ConfigValueType_1>;
getConfig: <ConfigValueType_2>(
key: loopbackContext.BindingAddress<unknown>,
propertyPath?: string | undefined,
resolutionOptions?: loopbackContext.ResolutionOptions | undefined
) => Promise<ConfigValueType_2>;
getConfigSync: <ConfigValueType_3>(
key: loopbackContext.BindingAddress<unknown>,
propertyPath?: string | undefined,
resolutionOptions?: loopbackContext.ResolutionOptions | undefined
) => ConfigValueType_3;
unbind: (key: loopbackContext.BindingAddress<unknown>) => boolean;
subscribe: (
observer: loopbackContext.ContextEventObserver
) => loopbackContext.Subscription;
unsubscribe: (observer: loopbackContext.ContextEventObserver) => boolean;
close: () => void;
isSubscribed: (observer: loopbackContext.ContextObserver) => boolean;
createView: <T_7 = unknown>(
filter: BindingFilter,
comparator?: loopbackContext.BindingComparator | undefined,
options?: Omit<loopbackContext.ResolutionOptions, 'session'> | undefined
) => loopbackContext.ContextView<T_7>;
contains: (key: loopbackContext.BindingAddress<unknown>) => boolean;
isBound: (key: loopbackContext.BindingAddress<unknown>) => boolean;
getOwnerContext: (
keyOrBinding:
| Readonly<Binding<unknown>>
| loopbackContext.BindingAddress<unknown>
) => Context | undefined;
getScopedContext: (
scope: BindingScope.APPLICATION | BindingScope.SERVER | BindingScope.REQUEST
) => Context | undefined;
getResolutionContext: (binding: Binding<unknown>) => Context | undefined;
isVisibleTo: (ctx: Context) => boolean;
find: <ValueType_1 = any>(
pattern?: string | RegExp | BindingFilter | undefined
) => Binding<ValueType_1>[];
findByTag: <ValueType_2 = any>(
tagFilter: RegExp | loopbackContext.BindingTag
) => Binding<ValueType_2>[];
get: {
<ValueType_3>(
keyWithPath: loopbackContext.BindingAddress<ValueType_3>,
session?: loopbackContext.ResolutionSession | undefined
): Promise<ValueType_3>;
<ValueType_4>(
keyWithPath: loopbackContext.BindingAddress<ValueType_4>,
options: loopbackContext.ResolutionOptions
): Promise<ValueType_4>;
};
getSync: {
<ValueType_5>(
keyWithPath: loopbackContext.BindingAddress<ValueType_5>,
session?: loopbackContext.ResolutionSession | undefined
): ValueType_5;
<ValueType_6>(
keyWithPath: loopbackContext.BindingAddress<ValueType_6>,
options?: loopbackContext.ResolutionOptions | undefined
): ValueType_6;
};
getBinding: {
<ValueType_7 = any>(
key: loopbackContext.BindingAddress<ValueType_7>
): Binding<ValueType_7>;
<ValueType_8>(
key: loopbackContext.BindingAddress<ValueType_8>,
options?: { optional?: boolean | undefined } | undefined
): any;
};
findOrCreateBinding: <T_8>(
key: loopbackContext.BindingAddress<T_8>,
policy?: loopbackContext.BindingCreationPolicy | undefined
) => Binding<T_8>;
getValueOrPromise: <ValueType_9>(
keyWithPath: loopbackContext.BindingAddress<ValueType_9>,
optionsOrSession?: loopbackContext.ResolutionOptionsOrSession | undefined
) => loopbackContext.ValueOrPromise<ValueType_9>;
toJSON: () => loopbackContext.JSONObject;
inspect: (
options?: loopbackContext.ContextInspectOptions | undefined
) => loopbackContext.JSONObject;
on: {
(
eventName: 'bind' | 'unbind',
listener: loopbackContext.ContextEventListener
): Application;
(event: string | symbol, listener: (...args: any[]) => void): Application;
};
once: {
(
eventName: 'bind' | 'unbind',
listener: loopbackContext.ContextEventListener
): Application;
(event: string | symbol, listener: (...args: any[]) => void): Application;
};
addListener: (
event: string | symbol,
listener: (...args: any[]) => void
) => Application;
removeListener: (
event: string | symbol,
listener: (...args: any[]) => void
) => Application;
off: (event: string | symbol, listener: (...args: any[]) => void) => Application;
removeAllListeners: (event?: string | symbol | undefined) => Application;
setMaxListeners: (n: number) => Application;
getMaxListeners: () => number;
listeners: (event: string | symbol) => Function[];
rawListeners: (event: string | symbol) => Function[];
emit: (event: string | symbol, ...args: any[]) => boolean;
listenerCount: (type: string | symbol) => number;
prependListener: (
event: string | symbol,
listener: (...args: any[]) => void
) => Application;
prependOnceListener: (
event: string | symbol,
listener: (...args: any[]) => void
) => Application;
eventNames: () => (string | symbol)[];
}) &
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[]

    Parameter superClass

    Application class

    Returns

    A new class that extends the super class with boot related methods

function createBooterForComponentApplication

createBooterForComponentApplication: (
componentApp: Application & Bootable,
filter?: BindingFilter
) => Constructor<Booter>;
  • Create a booter that boots the component application. Bindings that exist in the component application before boot are skipped. Locked bindings in the main application will not be overridden.

    Parameter componentApp

    The application exposing a component

    Parameter filter

    Binding filter to selected bindings to be added

function createComponentApplicationBooterBinding

createComponentApplicationBooterBinding: (
componentApp: Application & Bootable,
filter?: BindingFilter
) => Binding<Booter>;
  • Create a binding to register a booter that boots the component application. Bindings that exist in the component application before boot are skipped. Locked bindings in the main application will not be overridden.

    Parameter componentApp

    The application exposing a component

    Parameter filter

    Binding filter to selected bindings to be added

function discoverFiles

discoverFiles: (pattern: string, root: string) => Promise<string[]>;
  • Returns all files matching the given glob pattern relative to root

    Parameter pattern

    A glob pattern

    Parameter root

    Root folder to start searching for matching files

    Returns

    Array of discovered files

function isClass

isClass: (target: any) => target is Constructor<any>;
  • Given a function, returns true if it is a class, false otherwise.

    Parameter target

    The function to check if it's a class or not.

    Returns

    True if target is a class. False otherwise.

function loadClassesFromFiles

loadClassesFromFiles: (
files: string[],
projectRootDir: string
) => Constructor<{}>[];
  • 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.

    Parameter files

    An array of string of absolute file paths

    Parameter projectRootDir

    The project root directory

    Returns

    An array of Class constructors from a file

Classes

class ApplicationMetadataBooter

class ApplicationMetadataBooter implements Booter {}
  • Configure the application with metadata from package.json

    Parameter app

    Application instance

    Parameter projectRoot

    Root of User Project

constructor

constructor(app: Application, projectRoot: string);

    property app

    app: Application;

      method configure

      configure: () => Promise<void>;

        class BaseArtifactBooter

        class BaseArtifactBooter implements Booter {}
        • 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.

        constructor

        constructor(projectRoot: string, options: ArtifactOptions);

          property artifactName

          readonly artifactName: string;
          • Get the name of the artifact loaded by this booter, e.g. "Controller". Subclasses can override the default logic based on the class name.

          property classes

          classes: Constructor<{}>[];
          • List of exported classes discovered in the files

          property dirs

          dirs: string[];
          • Relative paths of directories to be searched

          property discovered

          discovered: string[];
          • List of files discovered by the Booter that matched artifact requirements

          property extensions

          extensions: string[];
          • File extensions to be searched

          property glob

          glob: string;
          • glob pattern to match artifact paths

          property options

          readonly options: ArtifactOptions;
          • Options being used by the Booter.

          property projectRoot

          readonly projectRoot: string;
          • Project root relative to which all other paths are resolved

          method configure

          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.

          method discover

          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.

          method load

          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.

          class BootComponent

          class BootComponent implements Component {}
          • 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

          constructor(app: Application);
          • Parameter app

            Application instance

          property booters

          booters: (
          | typeof ApplicationMetadataBooter
          | typeof ControllerBooter
          | typeof DataSourceBooter
          | typeof InterceptorProviderBooter
          | typeof LifeCycleObserverBooter
          | typeof ModelApiBooter
          | typeof ModelBooter
          | typeof RepositoryBooter
          | typeof ServiceBooter
          )[];

            class Bootstrapper

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

              Parameter app

              Application instance

              Parameter projectRoot

              The root directory of the project, relative to which all other paths are resolved

              Parameter bootOptions

              The BootOptions describing the conventions to be used by various Booters

            constructor

            constructor(app: any, projectRoot: string, bootOptions?: BootOptions);

              method boot

              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.

                Parameter execOptions

                Execution options for boot. These determine the phases and booters that are run.

                Parameter ctx

                Optional Context to use to resolve bindings. This is primarily useful when running app.boot() again but with different settings (in particular phases) such as 'start' / 'stop'. Using a returned Context from a previous boot call allows DI to retrieve the same instances of Booters previously used as they are bound using a CONTEXT scope. This is important as Booter instances may maintain state.

              class ControllerBooter

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

                Supported phases: configure, discover, load

                Parameter app

                Application instance

                Parameter projectRoot

                Root of User Project relative to which all paths are resolved

                Parameter bootConfig

                Controller Artifact Options Object

              constructor

              constructor(
              app: Application,
              projectRoot: string,
              controllerConfig?: ArtifactOptions
              );

                property app

                app: Application;

                  property controllerConfig

                  controllerConfig: ArtifactOptions;

                    method 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);.

                    class DataSourceBooter

                    class DataSourceBooter extends BaseArtifactBooter {}
                    • A class that extends BaseArtifactBooter to boot the 'DataSource' artifact type. Discovered DataSources are bound using app.dataSource().

                      Supported phases: configure, discover, load

                      Parameter app

                      Application instance

                      Parameter projectRoot

                      Root of User Project relative to which all paths are resolved

                      Parameter bootConfig

                      DataSource Artifact Options Object

                    constructor

                    constructor(
                    app: ApplicationWithRepositories,
                    projectRoot: string,
                    datasourceConfig?: ArtifactOptions
                    );

                      property app

                      app: ApplicationWithRepositories;

                        property datasourceConfig

                        datasourceConfig: ArtifactOptions;

                          method load

                          load: () => Promise<void>;
                          • Uses super method to get a list of Artifact classes. Boot each file by creating a DataSourceConstructor and binding it to the application class.

                          class InterceptorProviderBooter

                          class InterceptorProviderBooter extends BaseArtifactBooter {}
                          • A class that extends BaseArtifactBooter to boot the 'InterceptorProvider' artifact type.

                            Supported phases: configure, discover, load

                            Parameter app

                            Application instance

                            Parameter projectRoot

                            Root of User Project relative to which all paths are resolved

                            Parameter bootConfig

                            InterceptorProvider Artifact Options Object

                          constructor

                          constructor(
                          app: Application,
                          projectRoot: string,
                          interceptorConfig?: ArtifactOptions
                          );

                            property app

                            app: Application;

                              property interceptorConfig

                              interceptorConfig: ArtifactOptions;

                                property interceptors

                                interceptors: Constructor<Provider<Interceptor>>[];

                                  method load

                                  load: () => Promise<void>;
                                  • Uses super method to get a list of Artifact classes. Boot each file by creating a DataSourceConstructor and binding it to the application class.

                                  class LifeCycleObserverBooter

                                  class LifeCycleObserverBooter extends BaseArtifactBooter {}
                                  • A class that extends BaseArtifactBooter to boot the 'LifeCycleObserver' artifact type.

                                    Supported phases: configure, discover, load

                                    Parameter app

                                    Application instance

                                    Parameter projectRoot

                                    Root of User Project relative to which all paths are resolved

                                    Parameter bootConfig

                                    LifeCycleObserver Artifact Options Object

                                  constructor

                                  constructor(
                                  app: Application,
                                  projectRoot: string,
                                  observerConfig?: ArtifactOptions
                                  );

                                    property app

                                    app: Application;

                                      property observerConfig

                                      observerConfig: ArtifactOptions;

                                        property observers

                                        observers: Constructor<LifeCycleObserver>[];

                                          method load

                                          load: () => Promise<void>;
                                          • Uses super method to get a list of Artifact classes. Boot each file by creating a DataSourceConstructor and binding it to the application class.

                                          class ModelApiBooter

                                          class ModelApiBooter extends BaseArtifactBooter {}

                                            constructor

                                            constructor(
                                            app: ApplicationWithRepositories,
                                            projectRoot: string,
                                            getModelApiBuilders: Getter<ModelApiBuilder[]>,
                                            booterConfig?: ArtifactOptions
                                            );

                                              property app

                                              app: ApplicationWithRepositories;

                                                property booterConfig

                                                booterConfig: ArtifactOptions;

                                                  property getModelApiBuilders

                                                  getModelApiBuilders: Getter<ModelApiBuilder[]>;

                                                    method getApiBuilderForPattern

                                                    getApiBuilderForPattern: (pattern: string) => Promise<ModelApiBuilder>;
                                                    • Retrieve the API builder that matches the pattern provided

                                                      Parameter pattern

                                                      name of pattern for an API builder

                                                    method load

                                                    load: () => Promise<void>;
                                                    • Load the the model config files

                                                    method setupModel

                                                    setupModel: (configFile: string) => Promise<void>;
                                                    • Set up the loaded model classes

                                                    class ModelBooter

                                                    class ModelBooter extends BaseArtifactBooter {}
                                                    • A class that extends BaseArtifactBooter to boot the 'Model' artifact type.

                                                      Supported phases: configure, discover, load

                                                      Parameter app

                                                      Application instance

                                                      Parameter projectRoot

                                                      Root of User Project relative to which all paths are resolved

                                                      Parameter bootConfig

                                                      Model Artifact Options Object

                                                    constructor

                                                    constructor(
                                                    app: ApplicationWithRepositories,
                                                    projectRoot: string,
                                                    modelConfig?: ArtifactOptions
                                                    );

                                                      property app

                                                      app: ApplicationWithRepositories;

                                                        property modelConfig

                                                        modelConfig: ArtifactOptions;

                                                          method load

                                                          load: () => Promise<void>;
                                                          • Uses super method to get a list of Artifact classes. Boot each file by creating a DataSourceConstructor and binding it to the application class.

                                                          class RepositoryBooter

                                                          class RepositoryBooter extends BaseArtifactBooter {}
                                                          • 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

                                                            Parameter app

                                                            Application instance

                                                            Parameter projectRoot

                                                            Root of User Project relative to which all paths are resolved

                                                            Parameter bootConfig

                                                            Repository Artifact Options Object

                                                          constructor

                                                          constructor(
                                                          app: ApplicationWithRepositories,
                                                          projectRoot: string,
                                                          repositoryOptions?: ArtifactOptions
                                                          );

                                                            property app

                                                            app: ApplicationWithRepositories;

                                                              property repositoryOptions

                                                              repositoryOptions: ArtifactOptions;

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

                                                                class ServiceBooter

                                                                class ServiceBooter extends BaseArtifactBooter {}
                                                                • A class that extends BaseArtifactBooter to boot the 'Service' artifact type. Discovered services are bound using app.service().

                                                                  Supported phases: configure, discover, load

                                                                  Parameter app

                                                                  Application instance

                                                                  Parameter projectRoot

                                                                  Root of User Project relative to which all paths are resolved

                                                                  Parameter bootConfig

                                                                  Service Artifact Options Object

                                                                constructor

                                                                constructor(
                                                                app: ApplicationWithServices,
                                                                projectRoot: string,
                                                                serviceConfig?: ArtifactOptions
                                                                );

                                                                  property app

                                                                  app: ApplicationWithServices;

                                                                    property serviceConfig

                                                                    serviceConfig: ArtifactOptions;

                                                                      method load

                                                                      load: () => Promise<void>;
                                                                      • Uses super method to get a list of Artifact classes. Boot each file by creating a DataSourceConstructor and binding it to the application class.

                                                                      Interfaces

                                                                      interface Bootable

                                                                      interface Bootable {}
                                                                      • Interface to describe the additions made available to an Application that uses BootMixin.

                                                                      property bootOptions

                                                                      bootOptions?: BootOptions;
                                                                      • Options for boot

                                                                      property projectRoot

                                                                      projectRoot: string;
                                                                      • Root directory for the project to be booted

                                                                      method boot

                                                                      boot: () => Promise<void>;
                                                                      • Boot up the project

                                                                      method booters

                                                                      booters: (...booterClasses: Constructor<Booter>[]) => Binding[];
                                                                      • Register booters

                                                                        Parameter booterClasses

                                                                        A list of booter classes

                                                                      interface Booter

                                                                      interface Booter {}
                                                                      • Defines the requirements to implement a Booter for LoopBack applications: - configure() - discover() - load()

                                                                        A Booter will run through the above methods in order.

                                                                      method configure

                                                                      configure: () => Promise<void>;
                                                                      • Configure phase of the Booter. It should set options / defaults in this phase.

                                                                      method discover

                                                                      discover: () => Promise<void>;
                                                                      • Discover phase of the Booter. It should search for artifacts in this phase.

                                                                      method load

                                                                      load: () => Promise<void>;
                                                                      • Load phase of the Booter. It should bind the artifacts in this phase.

                                                                      interface InstanceWithBooters

                                                                      interface InstanceWithBooters {}
                                                                      • Interface to describe an object that may have an array of booters.

                                                                      property booters

                                                                      booters?: Constructor<Booter>[];

                                                                        Type Aliases

                                                                        type ArtifactOptions

                                                                        type ArtifactOptions = {
                                                                        /**
                                                                        * Array of directories to check for artifacts.
                                                                        * Paths must be relative. Defaults to ['controllers']
                                                                        */
                                                                        dirs?: string | string[];
                                                                        /**
                                                                        * Array of file extensions to match artifact
                                                                        * files in dirs. Defaults to ['.controller.js']
                                                                        */
                                                                        extensions?: string | string[];
                                                                        /**
                                                                        * A flag to control if artifact discovery should check nested
                                                                        * folders or not. Default to true
                                                                        */
                                                                        nested?: boolean;
                                                                        /**
                                                                        * A `glob` string to use when searching for files. This takes
                                                                        * precedence over other options.
                                                                        */
                                                                        glob?: string;
                                                                        };
                                                                        • Type definition for ArtifactOptions. These are the options supported by this Booter.

                                                                        type BootExecutionOptions

                                                                        type BootExecutionOptions = {
                                                                        /**
                                                                        * Optional array of Booter Classes to bind to the application before running bootstrapper.
                                                                        */
                                                                        booters?: Constructor<Booter>[];
                                                                        /**
                                                                        * Filter Object for Bootstrapper
                                                                        */
                                                                        filter?: {
                                                                        /**
                                                                        * Names of booters that should be run by Bootstrapper
                                                                        */
                                                                        booters?: string[];
                                                                        /**
                                                                        * Names of phases that should be run by Bootstrapper
                                                                        */
                                                                        phases?: string[];
                                                                        };
                                                                        /**
                                                                        * Additional Properties
                                                                        */
                                                                        [prop: string]: any;
                                                                        };
                                                                        • Options for boot() execution

                                                                        type BootOptions

                                                                        type BootOptions = {
                                                                        controllers?: ArtifactOptions;
                                                                        repositories?: ArtifactOptions;
                                                                        /**
                                                                        * Additional Properties
                                                                        */
                                                                        [prop: string]: any;
                                                                        };
                                                                        • Options to configure Bootstrapper

                                                                        Namespaces

                                                                        namespace BootBindings

                                                                        namespace BootBindings {}
                                                                        • Namespace for boot related binding keys

                                                                        variable BOOT_OPTIONS

                                                                        const BOOT_OPTIONS: BindingKey<BootOptions>;
                                                                        • Binding key for boot options

                                                                        variable BOOTER_PREFIX

                                                                        const BOOTER_PREFIX: string;

                                                                          variable BOOTERS

                                                                          const BOOTERS: string;
                                                                          • Booter binding namespace

                                                                          variable BOOTSTRAPPER_KEY

                                                                          const BOOTSTRAPPER_KEY: BindingKey<Bootstrapper>;
                                                                          • Binding key for binding the BootStrapper class

                                                                          variable PROJECT_ROOT

                                                                          const PROJECT_ROOT: BindingKey<string>;
                                                                          • Binding key for determining project root directory

                                                                          namespace BootTags

                                                                          namespace BootTags {}
                                                                          • Namespace for boot related tags

                                                                          variable BOOTER

                                                                          const BOOTER: string;

                                                                            variable BOOTER_TAG

                                                                            const BOOTER_TAG: string;
                                                                            • Deprecated

                                                                              Use BootTags.BOOTER instead.

                                                                            Package Files (18)

                                                                            Dependencies (8)

                                                                            Dev Dependencies (7)

                                                                            Peer Dependencies (1)

                                                                            Badge

                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@loopback/boot.

                                                                            • Markdown
                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@loopback/boot)
                                                                            • HTML
                                                                              <a href="https://www.jsdocs.io/package/@loopback/boot"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>