@ccci/micro-server 0.0.16 → 0.0.17

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 +9 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -78113,12 +78113,15 @@ class DatabaseConnector {
78113
78113
  }
78114
78114
  static async init() {
78115
78115
  DatabaseConnector.connections = [];
78116
+ let connections = [];
78116
78117
  const configPath = `${DatabaseConnector.rootDir}/config/config.json`;
78117
78118
  const configFile = Bun.file(configPath);
78118
78119
  const configs = await configFile.json();
78119
78120
  const config = configs[env];
78120
- DatabaseConnector.connection = new Sequelize(config);
78121
- DatabaseConnector.connections.push(DatabaseConnector.connection);
78121
+ const connection = new Sequelize(config);
78122
+ DatabaseConnector.connection = connection;
78123
+ connections.push(connection);
78124
+ return connections;
78122
78125
  }
78123
78126
  async initializeModels() {
78124
78127
  let files = fs.readdirSync(`${DatabaseConnector.rootDir}/models`).filter((file) => file.indexOf(".") !== 0 && file.slice(-3) === ".ts");
@@ -78137,8 +78140,8 @@ class DatabaseConnector {
78137
78140
  static getConnection() {
78138
78141
  return DatabaseConnector.connection;
78139
78142
  }
78140
- async connect() {
78141
- DatabaseConnector.connection.authenticate();
78143
+ async connect(connection) {
78144
+ connection.authenticate();
78142
78145
  }
78143
78146
  static getModel(modelName) {
78144
78147
  return DatabaseConnector.connection.models[modelName];
@@ -78215,8 +78218,9 @@ class ApplicationServer {
78215
78218
  app.use(import_express.default.json());
78216
78219
  app.use(import_express_fileupload.default());
78217
78220
  const db = new DatabaseConnector(path2);
78221
+ const conn = await DatabaseConnector.init();
78222
+ await db.connect(conn[0]);
78218
78223
  await db.initializeModels();
78219
- await db.connect();
78220
78224
  new RouterFactory(app, path2, "routes");
78221
78225
  app.listen(port, () => {
78222
78226
  console.log(`REST API server ready at: http://127.0.0.1:${port}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccci/micro-server",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",