@loopback/boot

  • Version 7.0.1
  • Published
  • 227 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
): Binding<Booter>;
component<C extends Component = Component>(
componentCtor: Constructor<C>,
nameOrOptions?: string | BindingFromClassOptions
): Binding<C>;
mountComponentBooters(
componentInstanceOrClass: Constructor<unknown> | InstanceWithBooters
): void;
readonly options: any;
readonly state: string;
controller: <T>(
controllerCtor: any,
nameOrOptions?: string | BindingFromClassOptions | undefined
) => Binding<T>;
server: <T_1 extends any>(
ctor: Constructor<T_1>,
nameOrOptions?: string | BindingFromClassOptions | undefined
) => Binding<T_1>;
servers: <T_2 extends any>(ctors: Constructor<T_2>[]) => Binding<any>[];
getServer: <T_3 extends any>(target: any) => Promise<T_3>;
init: () => Promise<void>;
onInit: (
fn: () => import('@loopback/core').ValueOrPromise<void>
) => Binding<any>;
onStart: (
fn: () => import('@loopback/core').ValueOrPromise<void>
) => Binding<any>;
stop: () => Promise<void>;
onStop: (
fn: () => import('@loopback/core').ValueOrPromise<void>
) => Binding<any>;
setMetadata: (metadata: any) => void;
lifeCycleObserver: <T_4 extends any>(
ctor: Constructor<T_4>,
nameOrOptions?: string | BindingFromClassOptions | undefined
) => Binding<T_4>;
service: <S>(
cls: any,
nameOrOptions?: string | import('@loopback/core').ServiceOptions | undefined
) => Binding<S>;
interceptor: (
interceptor:
| import('@loopback/core').Interceptor
| Constructor<
import('@loopback/core').Provider<
import('@loopback/core').Interceptor
>
>,
nameOrOptions?:
| string
| import('@loopback/core').InterceptorBindingOptions
| undefined
) => Binding<any>;
readonly name: string;
readonly subscriptionManager: any;
scope: BindingScope;
readonly parent: Context | undefined;
emitEvent: <T_5 extends any>(type: string, event: T_5) => void;
emitError: (err: unknown) => void;
bind: <ValueType = any>(key: any) => Binding<ValueType>;
add: (binding: Binding<unknown>) => Application;
configure: <ConfigValueType = any>(
key?: import('@loopback/core').BindingAddress | undefined
) => Binding<ConfigValueType>;
getConfigAsValueOrPromise: <ConfigValueType_1>(
key: any,
propertyPath?: string | undefined,
resolutionOptions?: import('@loopback/core').ResolutionOptions | undefined
) => any;
getConfig: <ConfigValueType_2>(
key: any,
propertyPath?: string | undefined,
resolutionOptions?: import('@loopback/core').ResolutionOptions | undefined
) => Promise<ConfigValueType_2>;
getConfigSync: <ConfigValueType_3>(
key: any,
propertyPath?: string | undefined,
resolutionOptions?: import('@loopback/core').ResolutionOptions | undefined
) => ConfigValueType_3;
unbind: (key: any) => boolean;
subscribe: (observer: any) => any;
unsubscribe: (observer: any) => boolean;
close: () => void;
isSubscribed: (observer: any) => boolean;
createView: <T_6 = unknown>(
filter: BindingFilter,
comparator?: import('@loopback/core').BindingComparator | undefined,
options?:
| Omit<import('@loopback/core').ResolutionOptions, 'session'>
| undefined
) => any;
contains: (key: any) => boolean;
isBound: (key: any) => boolean;
getOwnerContext: (
keyOrBinding:
| Readonly<Binding<unknown>>
| import('@loopback/core').BindingAddress
) => 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 | import('@loopback/core').BindingTag
) => Binding<ValueType_2>[];
get: {
<ValueType_3>(
keyWithPath: any,
session?: import('@loopback/core').ResolutionSession | undefined
): Promise<ValueType_3>;
<ValueType_4>(keyWithPath: any, options: any): Promise<ValueType_4>;
};
getSync: {
<ValueType_5>(
keyWithPath: any,
session?: import('@loopback/core').ResolutionSession | undefined
): ValueType_5;
<ValueType_6>(
keyWithPath: any,
options?: import('@loopback/core').ResolutionOptions | undefined
): ValueType_6;
};
getBinding: {
<ValueType_7 = any>(key: any): Binding<ValueType_7>;
<ValueType_8>(
key: any,
options?: { optional?: boolean | undefined } | undefined
): any;
};
findOrCreateBinding: <T_7>(
key: any,
policy?: import('@loopback/core').BindingCreationPolicy | undefined
) => Binding<T_7>;
getValueOrPromise: <ValueType_9>(
keyWithPath: any,
optionsOrSession?:
| import('@loopback/core').ResolutionOptionsOrSession
| undefined
) => any;
toJSON: () => import('@loopback/core').JSONObject;
inspect: (
options?: import('@loopback/core').ContextInspectOptions | undefined
) => any;
on: {
(eventName: 'bind' | 'unbind', listener: any): Application;
(event: string | symbol, listener: (...args: any[]) => void): Application;
};
once: {
(eventName: 'bind' | 'unbind', listener: any): Application;
(event: string | symbol, listener: (...args: any[]) => void): Application;
};
addListener: <K_1>(
eventName: string | symbol,
listener: (...args: any[]) => void
) => Application;
removeListener: <K_2>(
eventName: string | symbol,
listener: (...args: any[]) => void
) => Application;
off: <K_3>(
eventName: string | symbol,
listener: (...args: any[]) => void
) => Application;
removeAllListeners: (event?: string | symbol | undefined) => Application;
setMaxListeners: (n: number) => Application;
getMaxListeners: () => number;
listeners: <K_4>(eventName: string | symbol) => Function[];
rawListeners: <K_5>(eventName: string | symbol) => Function[];
emit: <K_6>(eventName: string | symbol, ...args: any[]) => boolean;
listenerCount: <K_7>(
eventName: string | symbol,
listener?: Function | undefined
) => number;
prependListener: <K_8>(
eventName: string | symbol,
listener: (...args: any[]) => void
) => Application;
prependOnceListener: <K_9>(
eventName: 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>