@loopback/core
- Version 6.1.3
- Published
- 181 kB
- 3 dependencies
- MIT license
Install
npm i @loopback/core
yarn add @loopback/core
pnpm add @loopback/core
Overview
The core foundation for LoopBack 4. It can also serve as the platform to build large-scale Node.js applications and frameworks.
Remarks
For examples of how to leverage @loopback/core
to build composable and extensible projects, check out the core tutorial.
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Namespaces
Variables
variable DEFAULT_ORDERED_GROUPS
const DEFAULT_ORDERED_GROUPS: string[];
variable lifeCycleObserverFilter
const lifeCycleObserverFilter: BindingTagFilter;
Find all life cycle observer bindings. By default, a binding tagged with
CoreTags.LIFE_CYCLE_OBSERVER
. It's used asBindingFilter
.
Functions
function addExtension
addExtension: ( context: Context, extensionPointName: string, extensionClass: Constructor<unknown>, options?: BindingFromClassOptions) => Binding<unknown>;
Register an extension for the given extension point to the context
Parameter context
Context object
Parameter extensionPointName
Name of the extension point
Parameter extensionClass
Class or a provider for an extension
Parameter options
Options Options for the creation of binding from class
function asLifeCycleObserver
asLifeCycleObserver: <T = unknown>(binding: Binding<T>) => Binding<T>;
A
BindingTemplate
function to configure the binding as life cycle observer by tagging it withCoreTags.LIFE_CYCLE_OBSERVER
.Parameter binding
Binding object
function asService
asService: (serviceInterface: ServiceInterface) => BindingTemplate;
Create a binding template for a service interface
Parameter serviceInterface
Service interface
function createServiceBinding
createServiceBinding: <S>( cls: ServiceOrProviderClass<S>, options?: ServiceOptions) => Binding<S>;
Create a service binding from a class or provider
Parameter cls
Service class or provider
Parameter options
Service options
function extensionFilter
extensionFilter: (...extensionPointNames: string[]) => BindingFilter;
A factory function to create binding filter for extensions of a named extension point
Parameter extensionPointNames
A list of names of extension points
function extensionFor
extensionFor: (...extensionPointNames: string[]) => BindingTemplate;
A factory function to create binding template for extensions of the given extension point
Parameter extensionPointNames
Names of the extension point
function extensionPoint
extensionPoint: (name: string, ...specs: BindingSpec[]) => ClassDecorator;
Decorate a class as a named extension point. If the decoration is not present, the name of the class will be used.
Parameter name
Name of the extension point
Example 1
import {extensionPoint} from '@loopback/core';@extensionPoint(GREETER_EXTENSION_POINT_NAME)export class GreetingService {// ...}
function extensions
extensions: typeof extensions;
Shortcut to inject extensions for the given extension point.
Parameter extensionPointName
Name of the extension point. If not supplied, we use the
name
tag from the extension point binding or the class name of the extension point class. If a class needs to inject extensions from multiple extension points, use differentextensionPointName
for different types of extensions.Parameter metadata
Optional injection metadata
Example 1
import {Getter} from '@loopback/context';import {extensionPoint, extensions} from '@loopback/core';@extensionPoint(GREETER_EXTENSION_POINT_NAME)export class GreetingService {constructor(@extensions() // Inject extensions for the extension pointprivate getGreeters: Getter<Greeter[]>,// ...) {// ...}
function filterByServiceInterface
filterByServiceInterface: (serviceInterface: ServiceInterface) => BindingFilter;
Create a binding filter by service class
Parameter serviceInterface
Service class matching the one used by
binding.toClass()
Parameter options
Options to control if subclasses should be skipped for matching
function isLifeCycleObserver
isLifeCycleObserver: (obj: object) => obj is LifeCycleObserver;
Test if an object implements LifeCycleObserver
Parameter obj
An object
function isLifeCycleObserverClass
isLifeCycleObserverClass: ( ctor: Constructor<unknown>) => ctor is Constructor<LifeCycleObserver>;
Test if a class implements LifeCycleObserver
Parameter ctor
A class
function lifeCycleObserver
lifeCycleObserver: (group?: string, ...specs: BindingSpec[]) => ClassDecorator;
Sugar decorator to mark a class as life cycle observer
Parameter group
Optional observer group name
Parameter specs
Optional bindings specs
function mountComponent
mountComponent: (app: Application, component: Component) => void;
Mount a component to an Application.
Parameter app
Application
Parameter component
Component instance
function service
service: ( serviceInterface?: ServiceInterface, metadata?: InjectionMetadata) => ( target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: | number | TypedPropertyDescriptor<any> | undefined) => void;
@service
injects a service instance that matches the class or interface.Parameter serviceInterface
Interface for the service. It can be in one of the following forms:
- A class, such as MyService - A string that identifies the interface, such as
'MyService'
- A symbol that identifies the interface, such asSymbol('MyService')
If not provided, the value is inferred from the design:type of the parameter or property
Example 1
const ctx = new Context();ctx.bind('my-service').toClass(MyService);ctx.bind('logger').toClass(Logger);export class MyController {constructor(@service(MyService) private myService: MyService) {}@service()private logger: Logger;}ctx.bind('my-controller').toClass(MyController);await myController = ctx.get<MyController>('my-controller');
Classes
class Application
class Application extends Context implements LifeCycleObserver {}
Application is the container for various types of artifacts, such as components, servers, controllers, repositories, datasources, connectors, and models.
constructor
constructor(parent: Context);
Create an application with the given parent context
Parameter parent
Parent context
constructor
constructor(config?: ApplicationConfig, parent?: Context);
Create an application with the given configuration and parent context
Parameter config
Application configuration
Parameter parent
Parent context
property options
readonly options: ApplicationConfig;
property state
readonly state: string;
Get the state of the application. The initial state is
created
and it can transition as follows bystart
andstop
:1. start - !started -> starting -> started - started -> started (no-op) 2. stop - (started | initialized) -> stopping -> stopped - ! (started || initialized) -> stopped (no-op)
Two types of states are expected: - stable, such as
started
andstopped
- in process, such asbooting
andstarting
Operations such as
start
andstop
can only be called at a stable state. The logic should immediately set the state to a new one indicating work in process, such asstarting
andstopping
.
method assertInStates
protected assertInStates: (op: string, ...states: string[]) => void;
Assert current state of the application to be one of the expected values
Parameter op
The operation name, such as 'boot', 'start', or 'stop'
Parameter states
Valid states
method assertNotInProcess
protected assertNotInProcess: (op: string) => void;
Assert there is no other operation is in progress, i.e., the state is not
*ing
, such asstarting
orstopping
.Parameter op
The operation name, such as 'boot', 'start', or 'stop'
method awaitState
protected awaitState: (state: string) => Promise<void>;
method component
component: <T extends Component = Component>( componentCtor: Constructor<T>, nameOrOptions?: string | BindingFromClassOptions) => Binding<T>;
Add a component to this application and register extensions such as controllers, providers, and servers from the component.
Parameter componentCtor
The component class to add.
Parameter nameOrOptions
Optional component name or options, default to the class name
Example 1
export class ProductComponent {controllers = [ProductController];repositories = [ProductRepo, UserRepo];providers = {[AUTHENTICATION_STRATEGY]: AuthStrategy,[AUTHORIZATION_ROLE]: Role,};};app.component(ProductComponent);
method controller
controller: <T>( controllerCtor: Constructor<T>, nameOrOptions?: string | BindingFromClassOptions) => Binding<T>;
Register a controller class with this application.
Parameter controllerCtor
The controller class (constructor function).
Parameter name
Optional controller name, default to the class name
Returns
The newly created binding, you can use the reference to further modify the binding, e.g. lock the value to prevent further modifications.
Example 1
class MyController {}app.controller(MyController).lock();
method getServer
getServer: <T extends Server>(target: Constructor<T> | string) => Promise<T>;
Retrieve the singleton instance for a bound server.
Parameter ctor
The constructor that was used to make the binding.
Returns
A Promise of server instance
method init
init: () => Promise<void>;
Initialize the application, and all of its registered observers. The application state is checked to ensure the integrity of
initialize
.If the application is already initialized, no operation is performed.
This method is automatically invoked by
start()
if the application is not initialized.
method interceptor
interceptor: ( interceptor: Interceptor | Constructor<Provider<Interceptor>>, nameOrOptions?: string | InterceptorBindingOptions) => Binding<Interceptor>;
Register an interceptor
Parameter interceptor
An interceptor function or provider class
Parameter nameOrOptions
Binding name or options
method lifeCycleObserver
lifeCycleObserver: <T extends LifeCycleObserver>( ctor: Constructor<T>, nameOrOptions?: string | BindingFromClassOptions) => Binding<T>;
Register a life cycle observer class
Parameter ctor
A class implements LifeCycleObserver
Parameter nameOrOptions
Optional name or options for the life cycle observer
method onInit
onInit: (fn: () => ValueOrPromise<void>) => Binding<LifeCycleObserver>;
Register a function to be called when the application initializes.
This is a shortcut for adding a binding for a LifeCycleObserver implementing a
init()
method.Parameter fn
The function to invoke, it can be synchronous (returning
void
) or asynchronous (returningPromise<void>
).Returns
The LifeCycleObserver binding created.
method onStart
onStart: (fn: () => ValueOrPromise<void>) => Binding<LifeCycleObserver>;
Register a function to be called when the application starts.
This is a shortcut for adding a binding for a LifeCycleObserver implementing a
start()
method.Parameter fn
The function to invoke, it can be synchronous (returning
void
) or asynchronous (returningPromise<void>
).Returns
The LifeCycleObserver binding created.
method onStop
onStop: (fn: () => ValueOrPromise<void>) => Binding<LifeCycleObserver>;
Register a function to be called when the application starts.
This is a shortcut for adding a binding for a LifeCycleObserver implementing a
start()
method.Parameter fn
The function to invoke, it can be synchronous (returning
void
) or asynchronous (returningPromise<void>
).Returns
The LifeCycleObserver binding created.
method server
server: <T extends Server>( ctor: Constructor<T>, nameOrOptions?: string | BindingFromClassOptions) => Binding<T>;
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.
Parameter server
The server constructor.
Parameter nameOrOptions
Optional override for name or options.
Returns
Binding for the server class
Example 1
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".
method servers
servers: <T extends Server>(ctors: Constructor<T>[]) => Binding[];
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.
Parameter ctors
An array of Server constructors.
Returns
An array of bindings for the registered server classes
Remarks
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";
method service
service: <S>( cls: ServiceOrProviderClass<S>, nameOrOptions?: string | ServiceOptions) => Binding<S>;
Add a service to this application.
Parameter cls
The service or provider class
Example 1
// Define a class to be bound via ctx.toClass()@injectable({scope: BindingScope.SINGLETON})export class LogService {log(msg: string) {console.log(msg);}}// Define a class to be bound via ctx.toProvider()import {v4 as uuidv4} from 'uuid';export class UuidProvider implements Provider<string> {value() {return uuidv4();}}// Register the local servicesapp.service(LogService);app.service(UuidProvider, 'uuid');export class MyController {constructor(@inject('services.uuid') private uuid: string,@inject('services.LogService') private log: LogService,) {}greet(name: string) {this.log(`Greet request ${this.uuid} received: ${name}`);return `${this.uuid}: ${name}`;}}
method setMetadata
setMetadata: (metadata: ApplicationMetadata) => void;
Set application metadata.
@loopback/boot
calls this method to populate the metadata frompackage.json
.Parameter metadata
Application metadata
method setState
protected setState: (state: string) => void;
Transition the application to a new state and emit an event
Parameter state
The new state
method setupShutdown
protected setupShutdown: () => (signal: string) => Promise<void>;
Set up signals that are captured to shutdown the application
method start
start: () => Promise<void>;
Start the application, and all of its registered observers. The application state is checked to ensure the integrity of
start
.If the application is not initialized, it calls first
init()
to initialize the application. This only happens ifstart()
is called for the first time.If the application is already started, no operation is performed.
method stop
stop: () => Promise<void>;
Stop the application instance and all of its registered observers. The application state is checked to ensure the integrity of
stop
.If the application is already stopped or not started, no operation is performed.
class LifeCycleObserverRegistry
class LifeCycleObserverRegistry implements LifeCycleObserver {}
A context-based registry for life cycle observers
constructor
constructor( context: Context, observersView: ContextView<LifeCycleObserver>, options?: LifeCycleObserverOptions);
property context
protected readonly context: Context;
property observersView
protected readonly observersView: ContextView<LifeCycleObserver>;
property options
protected readonly options: LifeCycleObserverOptions;
method getObserverGroup
protected getObserverGroup: (binding: Binding<LifeCycleObserver>) => string;
Get the group for a given life cycle observer binding
Parameter binding
Life cycle observer binding
method getObserverGroupsByOrder
getObserverGroupsByOrder: () => LifeCycleObserverGroup[];
Get observer groups ordered by the group
method init
init: () => Promise<void>;
Notify all life cycle observers by group of
init
method invokeObserver
protected invokeObserver: ( observer: LifeCycleObserver, event: keyof LifeCycleObserver) => Promise<void>;
Invoke an observer for the given event
Parameter observer
A life cycle observer
Parameter event
Event name
method notifyGroups
protected notifyGroups: ( events: (keyof LifeCycleObserver)[], groups: LifeCycleObserverGroup[], reverse?: boolean) => Promise<void>;
Emit events to the observer groups
Parameter events
Event names
Parameter groups
Observer groups
method notifyObservers
protected notifyObservers: ( observers: LifeCycleObserver[], bindings: Readonly<Binding<LifeCycleObserver>>[], event: keyof LifeCycleObserver) => Promise<void>;
Notify an observer group of the given event
Parameter group
A group of bindings for life cycle observers
Parameter event
Event name
method setOrderedGroups
setOrderedGroups: (groups: string[]) => void;
method sortObserverBindingsByGroup
protected sortObserverBindingsByGroup: ( bindings: Readonly<Binding<LifeCycleObserver>>[]) => LifeCycleObserverGroup[];
Sort the life cycle observer bindings so that we can start/stop them in the right order. By default, we can start other observers before servers and stop them in the reverse order
Parameter bindings
Life cycle observer bindings
method start
start: () => Promise<void>;
Notify all life cycle observers by group of
start
method stop
stop: () => Promise<void>;
Notify all life cycle observers by group of
stop
Interfaces
interface ApplicationConfig
interface ApplicationConfig {}
Configuration for application
property name
name?: string;
Name of the application context
property shutdown
shutdown?: ShutdownOptions;
Configuration for signals that shut down the application
index signature
[prop: string]: any;
Other properties
interface ApplicationMetadata
interface ApplicationMetadata extends JSONObject {}
Type description for
package.json
interface ClassMap
interface ClassMap {}
A map of classes to be bound to a context
index signature
[key: string]: Constructor<BoundValue>;
interface Component
interface Component {}
A component declares a set of artifacts so that they can be contributed to an application as a group
property bindings
bindings?: Binding[];
An array of bindings to be aded to the application context.
Example 1
const bindingX = Binding.bind('x').to('Value X');this.bindings = [bindingX]
property classes
classes?: ClassMap;
A map of classes to be bound to the application context.
Example 1
{'rest.body-parsers.xml': XmlBodyParser}
property components
components?: Constructor<Component>[];
An array of component classes
property controllers
controllers?: ControllerClass[];
An array of controller classes
property lifeCycleObservers
lifeCycleObservers?: Constructor<LifeCycleObserver>[];
property providers
providers?: ProviderMap;
A map of providers to be bound to the application context
Example 1
{'authentication.strategies.ldap': LdapStrategyProvider}
property servers
servers?: { [name: string]: Constructor<Server>;};
A map of name/class pairs for servers
property services
services?: ServiceOrProviderClass[];
An array of service or provider classes
index signature
[prop: string]: any;
Other properties
interface LifeCycleObserver
interface LifeCycleObserver {}
Observers to handle life cycle init/start/stop events
method init
init: (...injectedArgs: unknown[]) => ValueOrPromise<void>;
The method to be invoked during
init
. It will only be called at most once for a given application instance.
method start
start: (...injectedArgs: unknown[]) => ValueOrPromise<void>;
The method to be invoked during
start
method stop
stop: (...injectedArgs: unknown[]) => ValueOrPromise<void>;
The method to be invoked during
stop
interface ProviderMap
interface ProviderMap {}
A map of provider classes to be bound to a context
index signature
[key: string]: Constructor<Provider<BoundValue>>;
interface Server
interface Server extends LifeCycleObserver {}
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.
property listening
readonly listening: boolean;
Tells whether the server is listening for connections or not
interface ServiceOptions
interface ServiceOptions extends BindingFromClassOptions {}
Options to register a service binding
property interface
interface?: ServiceInterface;
Type Aliases
type ControllerClass
type ControllerClass<T = any> = Constructor<T>;
type LifeCycleObserverGroup
type LifeCycleObserverGroup = { /** * Observer group name */ group: string; /** * Bindings for observers within the group */ bindings: Readonly<Binding<LifeCycleObserver>>[];};
A group of life cycle observers
type LifeCycleObserverOptions
type LifeCycleObserverOptions = { /** * Control the order of observer groups for notifications. For example, * with `['datasource', 'server']`, the observers in `datasource` group are * notified before those in `server` group during `start`. Please note that * observers are notified in the reverse order during `stop`. */ orderedGroups: string[]; /** * Override and disable lifecycle observer groups. This setting applies to * both ordered groups (i.e. those defined in `orderedGroups`) and unordered * groups. */ disabledGroups?: string[]; /** * Notify observers of the same group in parallel, default to `true` */ parallel?: boolean;};
type MixinTarget
type MixinTarget<T extends object> = Constructor<{ [P in keyof T]: T[P];}>;
A replacement for
typeof Target
to be used in mixin class definitions. This is a workaround for TypeScript limitation described in - https://github.com/microsoft/TypeScript/issues/17293 - https://github.com/microsoft/TypeScript/issues/17744 - https://github.com/microsoft/TypeScript/issues/36060Example 1
export function MyMixin<T extends MixinTarget<Application>>(superClass: T) {return class extends superClass {// contribute new class members}};TypeScript does not allow class mixins to access protected members from the base class. You can use the following approach as a workaround:
// eslint-disable-next-line @typescript-eslint/ban-ts-comment// @ts-ignore(this as unknown as {YourBaseClass}).protectedMemberThe directive
@ts-ignore
suppresses compiler error about accessing a protected member from outside. Unfortunately, it also disables other compile-time checks (e.g. to verify that a protected method was invoked with correct arguments, and so on). This is the same behavior you would get by usingConstructor<any>
instead ofMixinTarget<Application>
. The major improvement is that TypeScript can still infer the return type of the protected member, thereforeany
is NOT introduced to subsequent code.TypeScript also does not allow mixin class to overwrite a method inherited from a mapped type, see https://github.com/microsoft/TypeScript/issues/38496 As a workaround, use
@ts-ignore
to disable the error.export function RepositoryMixin<T extends MixinTarget<Application>>(superClass: T,) {return class extends superClass {// @ts-ignorepublic component<C extends Component = Component>(componentCtor: Constructor<C>,nameOrOptions?: string | BindingFromClassOptions,) {const binding = super.component(componentCtor, nameOrOptions);// ...return binding;}}
type ServiceInterface
type ServiceInterface = string | symbol | Function;
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.
type ServiceOrProviderClass
type ServiceOrProviderClass<T = any> = | Constructor<T | Provider<T>> | DynamicValueProviderClass<T>;
type ShutdownOptions
type ShutdownOptions = { /** * An array of signals to be trapped for graceful shutdown */ signals?: NodeJS.Signals[]; /** * Period in milliseconds to wait for the grace shutdown to finish before * exiting the process */ gracePeriod?: number;};
Options to set up application shutdown
Namespaces
namespace CoreBindings
namespace CoreBindings {}
Namespace for core binding keys
variable APPLICATION_CONFIG
const APPLICATION_CONFIG: BindingKey<ApplicationConfig>;
Binding key for application configuration
variable APPLICATION_INSTANCE
const APPLICATION_INSTANCE: BindingKey<Application>;
Binding key for application instance itself
variable APPLICATION_METADATA
const APPLICATION_METADATA: BindingKey<ApplicationMetadata>;
Binding key for the content of
package.json
variable COMPONENTS
const COMPONENTS: string;
Binding key for components
variable CONTROLLER_CLASS
const CONTROLLER_CLASS: BindingKey<Constructor<T>>;
Binding key for the controller class resolved in the current request context
variable CONTROLLER_CURRENT
const CONTROLLER_CURRENT: BindingKey<unknown>;
Binding key for the controller instance resolved in the current request context
variable CONTROLLER_METHOD_META
const CONTROLLER_METHOD_META: string;
Binding key for the controller method metadata resolved in the current request context
variable CONTROLLER_METHOD_NAME
const CONTROLLER_METHOD_NAME: BindingKey<string>;
Binding key for the controller method resolved in the current request context
variable CONTROLLERS
const CONTROLLERS: string;
variable LIFE_CYCLE_OBSERVER_OPTIONS
const LIFE_CYCLE_OBSERVER_OPTIONS: BindingKey<LifeCycleObserverOptions>;
Binding key for life cycle observer options
variable LIFE_CYCLE_OBSERVER_REGISTRY
const LIFE_CYCLE_OBSERVER_REGISTRY: BindingKey<LifeCycleObserverRegistry>;
Binding key for life cycle observer options
variable LIFE_CYCLE_OBSERVERS
const LIFE_CYCLE_OBSERVERS: string;
variable SERVERS
const SERVERS: string;
Binding key for servers
namespace CoreTags
namespace CoreTags {}
variable COMPONENT
const COMPONENT: string;
Binding tag for components
variable CONTROLLER
const CONTROLLER: string;
Binding tag for controllers
variable EXTENSION_FOR
const EXTENSION_FOR: string;
Binding tag for extensions to specify name of the extension point that an extension contributes to.
variable EXTENSION_POINT
const EXTENSION_POINT: string;
Binding tag for an extension point to specify name of the extension point
variable LIFE_CYCLE_OBSERVER
const LIFE_CYCLE_OBSERVER: string;
Binding tag for life cycle observers
variable LIFE_CYCLE_OBSERVER_GROUP
const LIFE_CYCLE_OBSERVER_GROUP: string;
Binding tag for group name of life cycle observers
variable SERVER
const SERVER: string;
Binding tag for servers
variable SERVICE
const SERVICE: string;
Binding tag for services
variable SERVICE_INTERFACE
const SERVICE_INTERFACE: string;
Binding tag for the service interface
namespace extensions
namespace extensions {}
function list
list: ( extensionPointName?: string, metadata?: InjectionMetadata) => ( target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: | number | TypedPropertyDescriptor<any> | undefined) => void;
Inject an array of resolved extension instances for the extension point. The list is a snapshot of registered extensions when the injection is fulfilled. Extensions added or removed afterward won't impact the list.
Parameter extensionPointName
Name of the extension point. If not supplied, we use the
name
tag from the extension point binding or the class name of the extension point class. If a class needs to inject extensions from multiple extension points, use differentextensionPointName
for different types of extensions.Parameter metadata
Optional injection metadata
Example 1
import {extensionPoint, extensions} from '@loopback/core';@extensionPoint(GREETER_EXTENSION_POINT_NAME)export class GreetingService {constructor(@extensions.list() // Inject an array of extensions for the extension pointprivate greeters: Greeter[],// ...) {// ...}
function view
view: ( extensionPointName?: string, metadata?: InjectionMetadata) => ( target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: | number | TypedPropertyDescriptor<any> | undefined) => void;
Inject a
ContextView
for extensions of the extension point. The view can then be listened on events such asbind
,unbind
, orrefresh
to react on changes of extensions.Parameter extensionPointName
Name of the extension point. If not supplied, we use the
name
tag from the extension point binding or the class name of the extension point class. If a class needs to inject extensions from multiple extension points, use differentextensionPointName
for different types of extensions.Parameter metadata
Optional injection metadata
Example 1
import {extensionPoint, extensions} from '@loopback/core';@extensionPoint(GREETER_EXTENSION_POINT_NAME)export class GreetingService {constructor(@extensions.view() // Inject a context view for extensions of the extension pointprivate greetersView: ContextView<Greeter>,// ...) {// ...}
Package Files (10)
Dependencies (3)
Dev Dependencies (5)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto 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/core
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@loopback/core)
- HTML<a href="https://www.jsdocs.io/package/@loopback/core"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3826 ms. - Missing or incorrect documentation? Open an issue for this package.