Class: application = new Application()

Properties
Name Type Description
options ApplicationConfig

constructor(options: ApplicationConfig) : Application

Arguments
Name Type Description
options ApplicationConfig

component(component: Constructor) : void

Add a component to this application.

Arguments
Name Type Description
component Constructor

The component to add.


export class ProductComponent {
  controllers = [ProductController];
  repositories = [ProductRepo, UserRepo];
  providers = {
    [AUTHENTICATION_STRATEGY]: AuthStrategy,
    [AUTHORIZATION_ROLE]: Role,
  };
};

app.component(ProductComponent);

controller(controllerCtor: ControllerClass) : Binding

Register a controller class with this application.

Returns:

The newly created binding, you can use the reference to further modify the binding, e.g. lock the value to prevent further modifications.

class MyController {
}
app.controller(MyController).lock();

Arguments
Name Type Description
controllerCtor ControllerClass

The controller class (constructor function).

getServer(target: undefined) : Promise

Retrieve the singleton instance for a bound constructor.

Arguments
Name Type Description
target

server(ctor: Constructor, name: string) : void

Bind a Server constructor to the Application's master context. Each server constructor added in this way must provide a unique prefix to prevent binding overlap.

app.server(RestServer);
// This server constructor will be bound under "servers.RestServer".
app.server(RestServer, "v1API");
// This server instance will be bound under "servers.v1API".

Arguments
Name Type Description
ctor Constructor
name string

Optional override for key name.

servers(ctors: undefined) : void

Bind an array of Server constructors to the Application's master context. Each server added in this way will automatically be named based on the class constructor name with the "servers." prefix.

If you wish to control the binding keys for particular server instances, use the app.server function instead.

app.servers([
 RestServer,
 GRPCServer,
]);
// Creates a binding for "servers.RestServer" and a binding for
// "servers.GRPCServer";

Arguments
Name Type Description
ctors

An array of Server constructors.

start() : Promise

Start the application, and all of its registered servers.

stop() : Promise

Stop the application instance and all of its registered servers.

Interface: ApplicationConfig

Properties
Name Type Description
components Array
controllers Array
servers Function

ControllerClass = Constructor

Interface: Component

Properties
Name Type Description
controllers
providers ProviderMap
servers Function

Interface: ProviderMap

mountComponent(app: Application, component: Component) : void

Mount a component to an Application.

Arguments
Name Type Description
app Application

component Component

promisify(func: (callback: (err: any, result: T) => void) => void) :

Arguments
Name Type Description
func Function

Interface: Server

Defines the requirements to implement a Server for LoopBack applications: start() : Promise stop() : Promise It is recommended that each Server implementation creates its own child Context, which inherits from the parent Application context. This way, any Server-specific bindings will remain local to the Server instance, and will avoid polluting its parent module scope.

start() : Promise

stop() : Promise