UNPKG

2.03 kBTypeScriptView Raw
1import { Binding, BoundValue, Constructor, Provider } from '@loopback/context';
2import { Application, ControllerClass, ServiceOrProviderClass } from './application';
3import { LifeCycleObserver } from './lifecycle';
4import { Server } from './server';
5/**
6 * A map of provider classes to be bound to a context
7 */
8export interface ProviderMap {
9 [key: string]: Constructor<Provider<BoundValue>>;
10}
11/**
12 * A map of classes to be bound to a context
13 */
14export interface ClassMap {
15 [key: string]: Constructor<BoundValue>;
16}
17/**
18 * A component declares a set of artifacts so that they can be contributed to
19 * an application as a group
20 */
21export interface Component {
22 /**
23 * An array of controller classes
24 */
25 controllers?: ControllerClass[];
26 /**
27 * A map of providers to be bound to the application context
28 *
29 * @example
30 * ```ts
31 * {
32 * 'authentication.strategies.ldap': LdapStrategyProvider
33 * }
34 * ```
35 */
36 providers?: ProviderMap;
37 /**
38 * A map of classes to be bound to the application context.
39 *
40 * @example
41 * ```ts
42 * {
43 * 'rest.body-parsers.xml': XmlBodyParser
44 * }
45 * ```
46 */
47 classes?: ClassMap;
48 /**
49 * A map of name/class pairs for servers
50 */
51 servers?: {
52 [name: string]: Constructor<Server>;
53 };
54 lifeCycleObservers?: Constructor<LifeCycleObserver>[];
55 /**
56 * An array of service or provider classes
57 */
58 services?: ServiceOrProviderClass[];
59 /**
60 * An array of bindings to be aded to the application context.
61 *
62 * @example
63 * ```ts
64 * const bindingX = Binding.bind('x').to('Value X');
65 * this.bindings = [bindingX]
66 * ```
67 */
68 bindings?: Binding[];
69 /**
70 * Other properties
71 */
72 [prop: string]: any;
73}
74/**
75 * Mount a component to an Application.
76 *
77 * @param app - Application
78 * @param component - Component instance
79 */
80export declare function mountComponent(app: Application, component: Component): void;