1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | import {Application, CoreBindings, inject} from '@loopback/core';
|
7 | import debugModule from 'debug';
|
8 | import path from 'path';
|
9 | import {BootBindings} from '../keys';
|
10 | import {Booter} from '../types';
|
11 |
|
12 | const debug = debugModule('loopback:boot:booter:application-metadata');
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export class ApplicationMetadataBooter implements Booter {
|
22 | constructor(
|
23 | @inject(CoreBindings.APPLICATION_INSTANCE) public app: Application,
|
24 | @inject(BootBindings.PROJECT_ROOT) private projectRoot: string,
|
25 | ) {}
|
26 |
|
27 | async configure() {
|
28 | try {
|
29 |
|
30 | const pkg = require(path.resolve(this.projectRoot, '../package.json'));
|
31 | this.app.setMetadata(pkg);
|
32 | } catch (err) {
|
33 | debug('package.json not found', err);
|
34 | }
|
35 | }
|
36 | }
|