@ccci/micro-server 1.0.35 → 1.0.37

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.
Files changed (2) hide show
  1. package/dist/index.js +23 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -87557,20 +87557,23 @@ class DatabaseConnector {
87557
87557
  DatabaseConnector.rootDir = path;
87558
87558
  }
87559
87559
  static async init() {
87560
- DatabaseConnector.connections = [];
87561
- let connections = [];
87562
- const configPath = `${DatabaseConnector.rootDir}/config/db.config.ts`;
87563
- import(configPath).then((configs) => {
87564
- Logger.info("configs :>> ", configs);
87565
- Logger.info("configs.default() :>> ", configs.default);
87566
- Logger.info("configs.default() :>> ", configs.default["development"]);
87567
- const config = configs.default[env];
87568
- Logger.info("config :>> ", config);
87569
- const connection = new Sequelize(config);
87570
- DatabaseConnector.connection = connection;
87571
- connections.push(connection);
87560
+ return new Promise((resolve, reject) => {
87561
+ let connections = [];
87562
+ try {
87563
+ DatabaseConnector.connections = [];
87564
+ const configPath = `${DatabaseConnector.rootDir}/config/db.config.ts`;
87565
+ import(configPath).then((configs) => {
87566
+ const config = configs.default[env];
87567
+ const connection = new Sequelize(config);
87568
+ DatabaseConnector.connection = connection;
87569
+ connections.push(connection);
87570
+ });
87571
+ resolve(connections);
87572
+ } catch (error) {
87573
+ Logger.error(error);
87574
+ reject(connections);
87575
+ }
87572
87576
  });
87573
- return connections;
87574
87577
  }
87575
87578
  async initializeModels() {
87576
87579
  let files = fs.readdirSync(`${DatabaseConnector.rootDir}/models`).filter((file) => file.indexOf(".") !== 0 && file.slice(-3) === ".ts");
@@ -87590,7 +87593,13 @@ class DatabaseConnector {
87590
87593
  return DatabaseConnector.connection;
87591
87594
  }
87592
87595
  async connect(connection) {
87593
- connection.authenticate();
87596
+ try {
87597
+ Logger.info("Connecting to: ", connection);
87598
+ connection.authenticate();
87599
+ Logger.info("Connection to Database: Success!");
87600
+ } catch (error) {
87601
+ Logger.error(new Error("Connection to Database: ERROR!"));
87602
+ }
87594
87603
  }
87595
87604
  static getModel(modelName) {
87596
87605
  return DatabaseConnector.connection.models[modelName];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccci/micro-server",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",