@flutry/sequelize 0.0.4 → 0.0.6
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/utils/connect.d.ts +3 -0
- package/dist/utils/connect.js +16 -1
- package/package.json +2 -2
package/dist/utils/connect.d.ts
CHANGED
package/dist/utils/connect.js
CHANGED
|
@@ -8,6 +8,9 @@ const models_1 = require("../models/models");
|
|
|
8
8
|
class Flutry_Connect {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.functions = new function_1.Functions();
|
|
11
|
+
this.retryCount = 0;
|
|
12
|
+
this.maxRetries = 5; // Maximum retry attempts
|
|
13
|
+
this.retryDelay = 5000; // 5 seconds
|
|
11
14
|
this.init = async () => {
|
|
12
15
|
if (await this.functions.DBConfigVerify()) {
|
|
13
16
|
this.connect();
|
|
@@ -24,9 +27,21 @@ class Flutry_Connect {
|
|
|
24
27
|
await Flutry_Connect.sequelize.authenticate();
|
|
25
28
|
//Flutry_Sequelize.logger.info('Connection has been established successfully'); //! This line commented for now
|
|
26
29
|
await new models_1.Flutry_Models();
|
|
30
|
+
this.retryCount = 0; // Reset retry count on successful connection
|
|
27
31
|
}
|
|
28
32
|
catch (error) {
|
|
29
|
-
main_1.Flutry_Sequelize.logger.error(
|
|
33
|
+
main_1.Flutry_Sequelize.logger.error(`Unable to connect to the database. Attempt ${this.retryCount + 1}/${this.maxRetries}`);
|
|
34
|
+
if (this.retryCount < this.maxRetries) {
|
|
35
|
+
this.retryCount++;
|
|
36
|
+
main_1.Flutry_Sequelize.logger.info(`Retrying connection in ${this.retryDelay / 1000} seconds...`);
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
this.connect();
|
|
39
|
+
}, this.retryDelay);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
main_1.Flutry_Sequelize.logger.error('Maximum retry attempts reached. Unable to connect to database.');
|
|
43
|
+
this.retryCount = 0; // Reset for potential future attempts
|
|
44
|
+
}
|
|
30
45
|
}
|
|
31
46
|
};
|
|
32
47
|
this.init();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flutry/sequelize",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"dotenv": "^
|
|
14
|
+
"dotenv": "^17.0.0",
|
|
15
15
|
"mariadb": "^3.4.2",
|
|
16
16
|
"mysql2": "^3.14.1",
|
|
17
17
|
"sequelize": "^6.37.7"
|