mm-share-lib 0.0.27 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import { DataSource } from 'typeorm';
1
+ import { DataSource, DataSourceOptions } from 'typeorm';
2
2
  export declare class DataSourceManager {
3
- private configService;
3
+ private options;
4
4
  private static instance;
5
- private dataSources;
5
+ private readonly dataSources;
6
6
  private constructor();
7
- static getInstance(): DataSourceManager;
8
- getDBDataSource(dataSourceName: string): Promise<DataSource>;
7
+ static getInstance(options: DataSourceOptions): DataSourceManager;
8
+ getDataSource(dataSourceName: string): Promise<DataSource>;
9
9
  }
@@ -3,25 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataSourceManager = void 0;
4
4
  const typeorm_1 = require("typeorm");
5
5
  class DataSourceManager {
6
- constructor(configService) {
7
- this.configService = configService;
6
+ constructor(options) {
7
+ this.options = options;
8
8
  this.dataSources = {};
9
9
  }
10
- static getInstance() {
10
+ static getInstance(options) {
11
11
  if (!DataSourceManager.instance) {
12
+ DataSourceManager.instance = new DataSourceManager(options);
12
13
  }
13
14
  return DataSourceManager.instance;
14
15
  }
15
- async getDBDataSource(dataSourceName) {
16
+ async getDataSource(dataSourceName) {
16
17
  if (this.dataSources[dataSourceName]) {
17
18
  const dataSource = this.dataSources[dataSourceName];
18
19
  return dataSource.isInitialized
19
20
  ? dataSource
20
21
  : await dataSource.initialize();
21
22
  }
22
- const newDataSource = new typeorm_1.DataSource({});
23
+ const newDataSource = new typeorm_1.DataSource(this.options);
23
24
  this.dataSources[dataSourceName] = newDataSource;
24
- return await newDataSource.initialize();
25
+ return newDataSource.initialize();
25
26
  }
26
27
  }
27
28
  exports.DataSourceManager = DataSourceManager;
@@ -1 +1 @@
1
- {"version":3,"file":"datasource-mapper.js","sourceRoot":"","sources":["../../../../src/lib/datasource-mapper/datasource-mapper.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AA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