@bee.js/node 0.0.77 → 0.0.79

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/beehive.js CHANGED
@@ -268,7 +268,7 @@ module.exports = function hive(req = {}, res = {}, model = null) {
268
268
  let val = row[field];
269
269
 
270
270
  // TODO colocar escape para sql injection
271
- switch (model.schema[field].type) {
271
+ switch (model.schema[field]?.type) {
272
272
  case "char":
273
273
  case "varchar":
274
274
  case "text":
package/lib/ORM/beeORM.js CHANGED
@@ -136,6 +136,7 @@ module.exports = {
136
136
 
137
137
  // TODO pegar dinamicamnete database utilizada
138
138
  let db = configs.databases.default;
139
+ let pool;
139
140
 
140
141
  switch (db.type) {
141
142
  case "mssql": // TODO implementar na versao >=1.2
@@ -143,11 +144,12 @@ module.exports = {
143
144
  case "mongo": // TODO implementar na versao >=1.2
144
145
  return false;
145
146
  default:
146
- return mysql.createPool({
147
+ pool = mysql.createPool({
147
148
  acquireTimeout: 10000, // Tempo limite para tentar adquirir uma nova conexão
148
149
  connectTimeout: 10000, // Tempo limite para conectar ao banco de dados
149
150
  idleTimeout: 60000, // Tempo que uma conexão pode ficar inativa antes de ser fechada
150
151
  reconnect: true,
152
+ enableKeepAlive: true,
151
153
  ...db,
152
154
  host: db.host,
153
155
  user: db.user,
@@ -157,6 +159,20 @@ module.exports = {
157
159
  connectionLimit: db.connectionLimit || 10,
158
160
  queueLimit: db.queueLimit || 0,
159
161
  });
162
+
163
+ if (db.ping)
164
+ setInterval(async () => {
165
+ console.log("ping db");
166
+ try {
167
+ const connection = await pool.getConnection();
168
+ await connection.ping();
169
+ connection.release();
170
+ } catch (error) {
171
+ console.error("MySQL ping error:", { error });
172
+ }
173
+ }, db.ping);
174
+
175
+ return pool;
160
176
  }
161
177
  },
162
178
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bee.js/node",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "description": "A JavaScript framework for making Node.js API´s",
5
5
  "main": "index.js",
6
6
  "scripts": {