1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.DataSourceDefaults = exports.DataSourceBooter = void 0;
|
8 | const tslib_1 = require("tslib");
|
9 | const core_1 = require("@loopback/core");
|
10 | const keys_1 = require("../keys");
|
11 | const types_1 = require("../types");
|
12 | const base_artifact_booter_1 = require("./base-artifact.booter");
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | let DataSourceBooter = class DataSourceBooter extends base_artifact_booter_1.BaseArtifactBooter {
|
24 | constructor(app, projectRoot, datasourceConfig = {}) {
|
25 | super(projectRoot,
|
26 |
|
27 | Object.assign({}, exports.DataSourceDefaults, datasourceConfig));
|
28 | this.app = app;
|
29 | this.datasourceConfig = datasourceConfig;
|
30 | }
|
31 | |
32 |
|
33 |
|
34 |
|
35 | async load() {
|
36 | await super.load();
|
37 | |
38 |
|
39 |
|
40 |
|
41 |
|
42 | if (this.classes.length > 0) {
|
43 | if (!this.app.dataSource) {
|
44 | console.warn('app.dataSource() function is needed for DataSourceBooter. You can add ' +
|
45 | 'it to your Application using RepositoryMixin from @loopback/repository.');
|
46 | }
|
47 | else {
|
48 | this.classes.forEach(cls => {
|
49 | this.app.dataSource(cls);
|
50 | });
|
51 | }
|
52 | }
|
53 | }
|
54 | };
|
55 | exports.DataSourceBooter = DataSourceBooter;
|
56 | exports.DataSourceBooter = DataSourceBooter = tslib_1.__decorate([
|
57 | (0, types_1.booter)('datasources'),
|
58 | tslib_1.__param(0, (0, core_1.inject)(core_1.CoreBindings.APPLICATION_INSTANCE)),
|
59 | tslib_1.__param(1, (0, core_1.inject)(keys_1.BootBindings.PROJECT_ROOT)),
|
60 | tslib_1.__param(2, (0, core_1.config)()),
|
61 | tslib_1.__metadata("design:paramtypes", [Object, String, Object])
|
62 | ], DataSourceBooter);
|
63 |
|
64 |
|
65 |
|
66 | exports.DataSourceDefaults = {
|
67 | dirs: ['datasources'],
|
68 | extensions: ['.datasource.js'],
|
69 | nested: true,
|
70 | };
|
71 |
|
\ | No newline at end of file |