UNPKG

3.62 kBPlain TextView Raw
1// Copyright IBM Corp. and LoopBack contributors 2017,2020. All Rights Reserved.
2// Node module: @loopback/core
3// This file is licensed under the MIT License.
4// License text available at https://opensource.org/licenses/MIT
5
6import {BindingKey} from '@loopback/context';
7import {
8 Application,
9 ApplicationConfig,
10 ApplicationMetadata,
11 ControllerClass,
12} from './application';
13import {
14 LifeCycleObserverOptions,
15 LifeCycleObserverRegistry,
16} from './lifecycle-registry';
17
18/**
19 * Namespace for core binding keys
20 */
21export namespace CoreBindings {
22 // application
23 /**
24 * Binding key for application instance itself
25 */
26 export const APPLICATION_INSTANCE = BindingKey.create<Application>(
27 'application.instance',
28 );
29
30 /**
31 * Binding key for application configuration
32 */
33 export const APPLICATION_CONFIG: BindingKey<ApplicationConfig> =
34 BindingKey.create<ApplicationConfig>('application.config');
35
36 /**
37 * Binding key for the content of `package.json`
38 */
39 export const APPLICATION_METADATA = BindingKey.create<ApplicationMetadata>(
40 'application.metadata',
41 );
42
43 // server
44 /**
45 * Binding key for servers
46 */
47 export const SERVERS = 'servers';
48
49 // component
50 /**
51 * Binding key for components
52 */
53 export const COMPONENTS = 'components';
54
55 // controller
56 export const CONTROLLERS = 'controllers';
57
58 /**
59 * Binding key for the controller class resolved in the current request
60 * context
61 */
62 export const CONTROLLER_CLASS: BindingKey<ControllerClass> =
63 BindingKey.create<ControllerClass>('controller.current.ctor');
64
65 /**
66 * Binding key for the controller method resolved in the current request
67 * context
68 */
69 export const CONTROLLER_METHOD_NAME = BindingKey.create<string>(
70 'controller.current.operation',
71 );
72
73 /**
74 * Binding key for the controller method metadata resolved in the current
75 * request context
76 */
77 export const CONTROLLER_METHOD_META = 'controller.method.meta';
78
79 /**
80 * Binding key for the controller instance resolved in the current request
81 * context
82 */
83 export const CONTROLLER_CURRENT = BindingKey.create('controller.current');
84
85 export const LIFE_CYCLE_OBSERVERS = 'lifeCycleObservers';
86 /**
87 * Binding key for life cycle observer options
88 */
89 export const LIFE_CYCLE_OBSERVER_REGISTRY =
90 BindingKey.create<LifeCycleObserverRegistry>('lifeCycleObserver.registry');
91
92 /**
93 * Binding key for life cycle observer options
94 */
95 export const LIFE_CYCLE_OBSERVER_OPTIONS =
96 BindingKey.create<LifeCycleObserverOptions>('lifeCycleObserver.options');
97}
98
99export namespace CoreTags {
100 /**
101 * Binding tag for components
102 */
103 export const COMPONENT = 'component';
104
105 /**
106 * Binding tag for servers
107 */
108 export const SERVER = 'server';
109
110 /**
111 * Binding tag for controllers
112 */
113 export const CONTROLLER = 'controller';
114
115 /**
116 * Binding tag for services
117 */
118 export const SERVICE = 'service';
119 /**
120 * Binding tag for the service interface
121 */
122 export const SERVICE_INTERFACE = 'serviceInterface';
123
124 /**
125 * Binding tag for life cycle observers
126 */
127 export const LIFE_CYCLE_OBSERVER = 'lifeCycleObserver';
128
129 /**
130 * Binding tag for group name of life cycle observers
131 */
132 export const LIFE_CYCLE_OBSERVER_GROUP = 'lifeCycleObserverGroup';
133
134 /**
135 * Binding tag for extensions to specify name of the extension point that an
136 * extension contributes to.
137 */
138 export const EXTENSION_FOR = 'extensionFor';
139
140 /**
141 * Binding tag for an extension point to specify name of the extension point
142 */
143 export const EXTENSION_POINT = 'extensionPoint';
144}