Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| options |
ApplicationConfig
|
constructorProperty exported public optional |
Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models. |
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| options |
ApplicationConfig
|
optional |
Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models. |
Add a component to this application and register extensions such as controllers, providers, and servers from the component.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| componentCtor |
Constructor<Component>
|
The component class to add. |
||
| name |
undefined | string
|
optional |
Optional component name, default to the class name
|
Register a controller class with this application.
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();
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| controllerCtor |
ControllerClass
|
The controller class (constructor function). |
||
| name |
undefined | string
|
optional |
Optional controller name, default to the class name |
Retrieve the singleton instance for a bound constructor.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| target |
Constructor<T> | String
|
Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models. |
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".
Binding for the server class
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| ctor |
Constructor<T>
|
Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models. |
||
| name |
undefined | string
|
optional |
Optional override for key name. |
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";
An array of bindings for the registered server classes
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| ctors |
Constructor<T>[]
|
An array of Server constructors. |
Start the application, and all of its registered servers.
Stop the application instance and all of its registered servers.
Configuration for application
A component declares a set of artifacts so that they cane be contributed to an application as a group
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| controllers |
ControllerClass[]
|
exported optional |
An array of controller classes |
|
| providers |
ProviderMap
|
exported optional |
A map of name/class pairs for binding providers |
|
| servers |
undefined | anonymous
|
exported optional |
A map of name/class pairs for servers |
A map of name/class pairs for binding providers
Mount a component to an Application.
| Name | Type | Default Value | Flags | Description |
|---|---|---|---|---|
| app |
Application
|
|
||
| component |
Component
|
|
Namespace for core binding keys
Binding key for application configuration
Binding key for application instance itself
Binding key for the controller class resolved in the current request context
Binding key for the controller instance resolved in the current request context
Binding key for the controller method metadata resolved in the current request context
Binding key for the controller method resolved in the current request context
Binding key for servers
Defines the requirements to implement a Server for LoopBack applications:
start() : Promise
Start the server
Stop the server