UNPKG

1.82 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
3// Node module: @loopback/boot
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.booter = exports.BOOTER_PHASES = void 0;
8const core_1 = require("@loopback/core");
9const keys_1 = require("./keys");
10/**
11 * Export of an array of all the Booter phases supported by the interface
12 * above, in the order they should be run.
13 */
14exports.BOOTER_PHASES = ['configure', 'discover', 'load'];
15/**
16 * `@booter` decorator to mark a class as a `Booter` and specify the artifact
17 * namespace for the configuration of the booter
18 *
19 * @example
20 * ```ts
21 * @booter('controllers')
22 * export class ControllerBooter extends BaseArtifactBooter {
23 * constructor(
24 * @inject(CoreBindings.APPLICATION_INSTANCE) public app: Application,
25 * @inject(BootBindings.PROJECT_ROOT) projectRoot: string,
26 * @config()
27 * public controllerConfig: ArtifactOptions = {},
28 * ) {
29 * // ...
30 * }
31 * }
32 * ```
33 *
34 * @param artifactNamespace - Namespace for the artifact. It will be used to
35 * inject configuration from boot options. For example, the Booter class
36 * decorated with `@booter('controllers')` can receive its configuration via
37 * `@config()` from the `controllers` property of boot options.
38 *
39 * @param specs - Extra specs for the binding
40 */
41function booter(artifactNamespace, ...specs) {
42 return (0, core_1.injectable)({
43 tags: {
44 artifactNamespace,
45 [keys_1.BootTags.BOOTER]: keys_1.BootTags.BOOTER,
46 [core_1.ContextTags.NAMESPACE]: keys_1.BootBindings.BOOTERS,
47 },
48 }, ...specs);
49}
50exports.booter = booter;
51//# sourceMappingURL=types.js.map
\No newline at end of file