@ccci/micro-server 1.0.58 → 1.0.60

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.
package/dist/index.js CHANGED
@@ -113632,8 +113632,14 @@ class DatabaseConnector {
113632
113632
  static getModel(modelName) {
113633
113633
  return DatabaseConnector.connection.models[modelName];
113634
113634
  }
113635
- static sync(modelName, force = false) {
113636
- DatabaseConnector.connection.models[modelName].sync({ force });
113635
+ static async sync(modelName, force = false) {
113636
+ console.log("DatabaseConnector.connection.models :>> ", DatabaseConnector.connection.models);
113637
+ console.log("syncing model :>> ", modelName);
113638
+ try {
113639
+ await DatabaseConnector.connection.models[modelName].sync({ force });
113640
+ } catch (error) {
113641
+ console.log("ERROR in syncing :>> ", error);
113642
+ }
113637
113643
  }
113638
113644
  static disconnect() {
113639
113645
  DatabaseConnector.connection.close();
@@ -119148,7 +119154,7 @@ class WebSocketServer {
119148
119154
  // src/utils/ApplicationServer.ts
119149
119155
  class ApplicationServer {
119150
119156
  static app;
119151
- static async bootstrap(port, options) {
119157
+ static async bootstrap(port, options, sync) {
119152
119158
  ApplicationServer.app = import_express.default();
119153
119159
  ApplicationServer.app.use(import_cors.default());
119154
119160
  ApplicationServer.app.use(helmet());
@@ -119173,6 +119179,11 @@ class ApplicationServer {
119173
119179
  const mailer = Mailer.getInstance();
119174
119180
  mailer.connect(options);
119175
119181
  }
119182
+ if (sync) {
119183
+ sync.forEach((model) => {
119184
+ DatabaseConnector.sync(model, true);
119185
+ });
119186
+ }
119176
119187
  });
119177
119188
  }
119178
119189
  getInstance() {
@@ -10,7 +10,7 @@ export default class ApplicationServer {
10
10
  * @param {number} port port for the micro service
11
11
  * @param {ApplicationOptionType} options additional server configuration
12
12
  */
13
- static bootstrap(port: number, options?: ApplicationOptionType): Promise<void>;
13
+ static bootstrap(port: number, options?: ApplicationOptionType, sync?: Array<string>): Promise<void>;
14
14
  getInstance(): express.Application;
15
15
  }
16
16
  //# sourceMappingURL=ApplicationServer.d.ts.map
@@ -18,7 +18,7 @@ export default class DatabaseConnector {
18
18
  static getConnection(): Sequelize;
19
19
  connect(connection: Sequelize): Promise<void>;
20
20
  static getModel(modelName: string): ModelStatic<Model>;
21
- static sync(modelName: string, force?: boolean): void;
21
+ static sync(modelName: string, force?: boolean): Promise<void>;
22
22
  static disconnect(): void;
23
23
  }
24
24
  //# sourceMappingURL=DatabaseConnector.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccci/micro-server",
3
- "version": "1.0.58",
3
+ "version": "1.0.60",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",