Socket
Socket
Sign inDemoInstall

hapi-plugin-mysql

Package Overview
Dependencies
41
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.2.6 to 7.2.7

.idea/hapi-plugin-mysql.iml

30

lib/index.js

@@ -18,4 +18,2 @@ 'use strict';

request.app.connection = connection;
// Since commit/rollback/beginTransaction uses the .query it will auto promisify them
request.app.connection.query = Util.promisify(connection.query);

@@ -34,11 +32,2 @@ return h.continue;

if (!callback) {
const connection = await internals.getConnection();
// Since commit/rollback/beginTransaction uses the .query it will auto promisify them
connection.query = Util.promisify(connection.query);
return connection;
}
let connection;

@@ -49,6 +38,14 @@ try {

catch (err) {
return callback(err);
if (callback) {
return callback(err);
}
throw err;
}
return callback(null, connection);
if (callback) {
return callback(null, connection);
}
return connection;
};

@@ -68,2 +65,7 @@

// Since commit/rollback/beginTransaction uses the .query it will auto promisify them
// Node's `util.promisify` adds a symbol with the promisified version of the function
// After promisifying `connection.query` also still works with callbacks
connection.query = Util.promisify(connection.query);
return resolve(connection);

@@ -161,5 +163,3 @@ });

server.log(['hapi-plugin-mysql', 'database'], 'Connection to the database successful');
}
};
{
"name": "hapi-plugin-mysql",
"version": "7.2.6",
"version": "7.2.7",
"description": "Hapi plugin for MySQL",

@@ -9,3 +9,3 @@ "main": "lib/index.js",

"lint": "eslint --fix .",
"test": "lab -a @hapi/code -vL --lint-fix -t 96"
"test": "lab -m 5000 -a @hapi/code -vL --lint-fix -t 95"
},

@@ -12,0 +12,0 @@ "repository": {

@@ -456,3 +456,23 @@ 'use strict';

});
it('Promisified `.query` usage with callbacks', async () => {
const MySQLPlugin = require('..');
await MySQLPlugin.init(internals.dbOptions);
const connection = await MySQLPlugin.getConnection();
return new Promise((resolve) => {
return connection.query('INSERT INTO test SET id = null', (err, results) => {
expect(err, 'error').to.not.exist();
expect(results.insertId, 'insert Id').to.exist();
return resolve();
});
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc