UNPKG

1.75 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. and LoopBack contributors 2018,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.ApplicationMetadataBooter = void 0;
8const tslib_1 = require("tslib");
9const core_1 = require("@loopback/core");
10const debug_1 = tslib_1.__importDefault(require("debug"));
11const path_1 = tslib_1.__importDefault(require("path"));
12const keys_1 = require("../keys");
13const debug = (0, debug_1.default)('loopback:boot:booter:application-metadata');
14/**
15 *
16 * Configure the application with metadata from `package.json`
17 *
18 * @param app - Application instance
19 * @param projectRoot - Root of User Project
20 */
21let ApplicationMetadataBooter = class ApplicationMetadataBooter {
22 constructor(app, projectRoot) {
23 this.app = app;
24 this.projectRoot = projectRoot;
25 }
26 async configure() {
27 try {
28 // `this.projectRoot` points to `<project>/dist`
29 const pkg = require(path_1.default.resolve(this.projectRoot, '../package.json'));
30 this.app.setMetadata(pkg);
31 }
32 catch (err) {
33 debug('package.json not found', err);
34 }
35 }
36};
37ApplicationMetadataBooter = tslib_1.__decorate([
38 tslib_1.__param(0, (0, core_1.inject)(core_1.CoreBindings.APPLICATION_INSTANCE)),
39 tslib_1.__param(1, (0, core_1.inject)(keys_1.BootBindings.PROJECT_ROOT)),
40 tslib_1.__metadata("design:paramtypes", [core_1.Application, String])
41], ApplicationMetadataBooter);
42exports.ApplicationMetadataBooter = ApplicationMetadataBooter;
43//# sourceMappingURL=application-metadata.booter.js.map
\No newline at end of file