Page Contents

Home > @loopback/core

core package

The core foundation for LoopBack 4. It can also serve as the platform to build large-scale Node.js applications and frameworks.


For examples of how to leverage @loopback/core to build composable and extensible projects, check out the core tutorial.


Class Description
Application Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.
LifeCycleObserverRegistry A context-based registry for life cycle observers


Function Description
addExtension(context, extensionPointName, extensionClass, options) Register an extension for the given extension point to the context
asLifeCycleObserver(binding) A BindingTemplate function to configure the binding as life cycle observer by tagging it with CoreTags.LIFE_CYCLE_OBSERVER.
asService(serviceInterface) Create a binding template for a service interface
createServiceBinding(cls, options) Create a service binding from a class or provider
extensionFilter(extensionPointNames) A factory function to create binding filter for extensions of a named extension point
extensionFor(extensionPointNames) A factory function to create binding template for extensions of the given extension point
extensionPoint(name, specs) Decorate a class as a named extension point. If the decoration is not present, the name of the class will be used.
extensions(extensionPointName, metadata) Shortcut to inject extensions for the given extension point.
filterByServiceInterface(serviceInterface) Create a binding filter by service class
isLifeCycleObserver(obj) Test if an object implements LifeCycleObserver
isLifeCycleObserverClass(ctor) Test if a class implements LifeCycleObserver
lifeCycleObserver(group, specs) Sugar decorator to mark a class as life cycle observer
mountComponent(app, component) Mount a component to an Application.
service(serviceInterface, metadata) @service injects a service instance that matches the class or interface.


Interface Description
ApplicationConfig Configuration for application
ApplicationMetadata Type description for package.json
ClassMap A map of classes to be bound to a context
Component A component declares a set of artifacts so that they can be contributed to an application as a group
LifeCycleObserver Observers to handle life cycle init/start/stop events
ProviderMap A map of provider classes to be bound to a context
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.
ServiceOptions Options to register a service binding


Namespace Description
CoreBindings Namespace for core binding keys


Variable Description
lifeCycleObserverFilter Find all life cycle observer bindings. By default, a binding tagged with CoreTags.LIFE_CYCLE_OBSERVER. It’s used as BindingFilter.

Type Aliases

Type Alias Description
LifeCycleObserverGroup A group of life cycle observers
MixinTarget A replacement for typeof Target to be used in mixin class definitions. This is a workaround for TypeScript limitation described in - - -
ServiceInterface Representing an interface for services. In TypeScript, the interface does not have reflections at runtime. We use a string, a symbol or a Function as the type for the service interface.
ShutdownOptions Options to set up application shutdown