exodus-framework 2.0.956 → 2.0.958
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/lib/app/settings.js
CHANGED
@@ -73,11 +73,11 @@ class CoreSettings {
|
|
73
73
|
return;
|
74
74
|
},
|
75
75
|
pool: {
|
76
|
-
max:
|
76
|
+
max: 5,
|
77
77
|
// Número máximo de conexões no pool
|
78
|
-
min:
|
78
|
+
min: 1,
|
79
79
|
// Número mínimo de conexões no pool
|
80
|
-
acquire:
|
80
|
+
acquire: 20000,
|
81
81
|
// Tempo máximo (em ms) para adquirir uma conexão do pool
|
82
82
|
idle: 10000 // Tempo máximo (em ms) que uma conexão pode ficar inativa
|
83
83
|
}
|
@@ -11,6 +11,13 @@ declare class DatabaseService extends Service {
|
|
11
11
|
private initConnection;
|
12
12
|
createConnection(host: string, port: number, database: string, username: string, password: string, dialect: Dialect): Promise<Sequelize>;
|
13
13
|
getConnection(tenantId: string): Promise<Sequelize>;
|
14
|
+
testConnection(data: {
|
15
|
+
host: string;
|
16
|
+
port: number;
|
17
|
+
username: string;
|
18
|
+
password: string;
|
19
|
+
dialect: Dialect;
|
20
|
+
}): Promise<boolean>;
|
14
21
|
getTenantIds(): Promise<string[]>;
|
15
22
|
getTenantInformation(tenantId: string): Promise<EnvDBHost>;
|
16
23
|
private loadEntity;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/services/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAsB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAgB,SAAS,EAAE,MAAM,WAAW,CAAC;AAIpD,cAAM,eAAgB,SAAQ,OAAO;IACnC,OAAO,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AU;IASX,SAAS,CAAC,CAAC,SAAS,YAAY,CAAC,KAAK,CAAC,EAClD,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAU1B,OAAO,CAAC,qBAAqB;CAG9B;AAED,eAAe,eAAe,CAAC"}
|
package/lib/services/database.js
CHANGED
@@ -93,6 +93,28 @@ class DatabaseService extends _app.Service {
|
|
93
93
|
}
|
94
94
|
return this.connections.get(tenantId);
|
95
95
|
}
|
96
|
+
async testConnection(data) {
|
97
|
+
const sequelize = new _sequelize.Sequelize({
|
98
|
+
host: data.host,
|
99
|
+
port: data.port,
|
100
|
+
username: data.username,
|
101
|
+
password: data.password,
|
102
|
+
dialect: data.dialect,
|
103
|
+
timezone: '-03:00',
|
104
|
+
pool: _app.Core.settings.getDatabase().service.pool,
|
105
|
+
logging: _app.Core.settings.getDatabase().service.log
|
106
|
+
});
|
107
|
+
return new Promise(resolve => {
|
108
|
+
sequelize.authenticate().then(async () => {
|
109
|
+
resolve(true);
|
110
|
+
}).catch(reason => {
|
111
|
+
new _app.ErrorHandler('teste de conexão falhou', reason);
|
112
|
+
resolve(false);
|
113
|
+
}).finally(() => {
|
114
|
+
sequelize.close();
|
115
|
+
});
|
116
|
+
});
|
117
|
+
}
|
96
118
|
|
97
119
|
//* Environment
|
98
120
|
async getTenantIds() {
|