hapi-plugin-mysql
Advanced tools
Sorry, the diff of this file is not supported yet
| <component name="InspectionProjectProfileManager"> | ||
| <profile version="1.0"> | ||
| <option name="myName" value="Project Default" /> | ||
| <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" /> | ||
| </profile> | ||
| </component> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="ProjectModuleManager"> | ||
| <modules> | ||
| <module fileurl="file://$PROJECT_DIR$/.idea/hapi-plugin-mysql.iml" filepath="$PROJECT_DIR$/.idea/hapi-plugin-mysql.iml" /> | ||
| </modules> | ||
| </component> | ||
| </project> |
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| <component name="VcsDirectoryMappings"> | ||
| <mapping directory="$PROJECT_DIR$" vcs="Git" /> | ||
| </component> | ||
| </project> |
+15
-15
@@ -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'); | ||
| } | ||
| }; |
+2
-2
| { | ||
| "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": { |
+20
-0
@@ -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(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23577
8.43%12
50%455
3.17%1
Infinity%