{"_id":"@cospired/hapi-plugin-mysql-promise","_rev":"5-28cb2fc29599709a8efa8ce5067a43da","name":"@cospired/hapi-plugin-mysql-promise","dist-tags":{"latest":"2.1.0"},"versions":{"1.0.0":{"name":"@cospired/hapi-plugin-mysql-promise","version":"1.0.0","description":"Hapi plugin for MySQL","main":"lib/index.js","scripts":{"test":"node node_modules/.bin/lab -a code -v -t 100","test-cov-html":"node node_modules/.bin/lab -a code -vL -t 100 -r html"},"repository":{"type":"git","url":"git+https://github.com/cospired/hapi-plugin-mysql-promise.git"},"keywords":["hapi","mysql","mysql2","promise","plugin"],"contributors":[{"name":"Adri Van Houdt","email":"adri.van.houdt@gmail.com"},{"name":"Jan Schmidle","email":"jan@cospired.com"},{"name":"Dirk Haage"}],"license":"MIT","bugs":{"url":"https://github.com/cospired/hapi-plugin-mysql-promise/issues"},"homepage":"https://github.com/cospired/hapi-plugin-mysql-promise","dependencies":{"hoek":"^4.2.1","mysql2":"^1.5.2"},"peerDependencies":{"hapi":">=9.x.x"},"engines":{"node":">=4.0.0"},"devDependencies":{"code":"4.x.x","hapi":"16.x.x","lab":"^14.3.2"},"gitHead":"b75282676e0785e378fbee417be0b2cd1a215f4e","_id":"@cospired/hapi-plugin-mysql-promise@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"8.8.1","_npmUser":{"name":"e110c0","email":"dirk+npm@cospired.com"},"dist":{"integrity":"sha512-Vwsxf9Ubw3i0Z/KqCfyqFBK0XsgMSRmOH+GuK94+BBRyeQQAYSt0rPTO/oGZm078BhYvACWb4qr59peaAjeUAA==","shasum":"8cfce382a5bbd3df88a042a5260de7ab0682f351","tarball":"https://registry.npmjs.org/@cospired/hapi-plugin-mysql-promise/-/hapi-plugin-mysql-promise-1.0.0.tgz","fileCount":6,"unpackedSize":21565,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC5h7U7trX9zifqTqtRBtgwQ5J1vUkg63dKS7UhTsI7/wIhALNsuhmE79rDy2xgC9bLZ8dl28cZJNhZewf6ucLQe6Vp"}]},"maintainers":[{"name":"bitcloud","email":"jan@jschmidle.org"},{"name":"e110c0","email":"dirk+npm@cospired.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hapi-plugin-mysql-promise_1.0.0_1520618101816_0.19690737760787935"},"_hasShrinkwrap":false},"2.0.0":{"name":"@cospired/hapi-plugin-mysql-promise","version":"2.0.0","description":"Hapi plugin for MySQL","main":"lib/index.js","private":false,"scripts":{"test":"node node_modules/.bin/lab -a code -v -t 100","test-cov-html":"node node_modules/.bin/lab -a code -vL -t 100 -r html"},"repository":{"type":"git","url":"git+https://github.com/cospired/hapi-plugin-mysql-promise.git"},"keywords":["hapi","mysql","mysql2","promise","plugin"],"contributors":[{"name":"Adri Van Houdt","email":"adri.van.houdt@gmail.com"},{"name":"Jan Schmidle","email":"jan@cospired.com"},{"name":"Dirk Haage"}],"license":"MIT","bugs":{"url":"https://github.com/cospired/hapi-plugin-mysql-promise/issues"},"homepage":"https://github.com/cospired/hapi-plugin-mysql-promise","dependencies":{"hoek":"^4.2.1","mysql2":"^1.6.1"},"peerDependencies":{"hapi":">=9.x.x"},"engines":{"node":">=8.0.0"},"devDependencies":{"code":"4.x.x","hapi":"16.x.x","lab":"^16.1.0"},"gitHead":"7cf28bffae88a41f32f9f0513e744b400beef68c","_id":"@cospired/hapi-plugin-mysql-promise@2.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"e110c0","email":"dirk+npm@cospired.com"},"dist":{"integrity":"sha512-2WB2tmfb4RzUgTaz/ipNUrXg2YYIUQNvXTwvK81S+y0OLpt86p1rpPd/+gKei6G2Y8Lnco62isOXB7Le6ZahfQ==","shasum":"4a9d550f61630bcb759a061d01551fb6b44be568","tarball":"https://registry.npmjs.org/@cospired/hapi-plugin-mysql-promise/-/hapi-plugin-mysql-promise-2.0.0.tgz","fileCount":6,"unpackedSize":21518,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvgP4CRA9TVsSAnZWagAA/KEP/jrtDuOpEsmOoDJOewUI\nb5uSrlKZmpUEhD8Ij8J/26ffIjITC/dcF6ldmYyuzYpd2xudXu82tpSdtHaI\nFVeh6Bem2f4y1atKj1zEYJ4gsHLOtXbu/k8xc5QKIZseajYQWa3UZL44DMb1\nsumvdroN5v1J8D5Qc0RfhC/zbVaxlsvjG6DTOIuX2CsRz7R0A2GnWSFRCYLi\noKUtfR4zCD4ODw6YzcF8geKJWr5WsCeoDAfqC00VPboiF0LzhIbcZRdpFNX9\n+Bz2rUjceUPPKlvYazUTup6hg6aMAwKH4CglwdZbMI6wd56umO1k4R7WCWau\nL6GbaSDNj6X8rrdmil7U34bmP+rKr2d5G6V/g7gNkhU7eUlyt9MDRBMCd54g\nXrf49rGaacbJ4BRedAWmMTJ0D8bSViSmiP7xOUjeaOSUk46qvCdenXR2rRvL\nsInjwPNSQi0LdvbOgvVa902hUoFDQtjiLB9Acn13p8Uowx2EilOaqNLJ+DF7\nwi+100MwwOoWIz2Q9F944qzDY1gRYuoD8d7ur0NMwwOmkH2+DS/nliT6kjw0\nyeaaUknTQ/polZpNT62IbZ27VbPlDtmjUjrDBBQLVSKDCq0/qNCypeaTkpTZ\nsWayLBybyR8efJphSepgc80gb3zfoHOqVSIcNmnBVMhBUM3u1d7hvAT2LQJO\nXOO2\r\n=cFEB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB/GuHiHlHiZLOSlstHyQGFcX4PoDBYp35RKKYOgDq3+AiEA+PQts6IKJ7TMWYn6N9z9Tx6+nsjhfzJ87CcUIVkOsKM="}]},"maintainers":[{"name":"bitcloud","email":"jan@jschmidle.org"},{"name":"e110c0","email":"dirk+npm@cospired.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hapi-plugin-mysql-promise_2.0.0_1539179511993_0.8899154151319022"},"_hasShrinkwrap":false},"2.0.1":{"name":"@cospired/hapi-plugin-mysql-promise","version":"2.0.1","description":"Hapi plugin for MySQL","main":"lib/index.js","private":false,"scripts":{"test":"lab -v -t 100","test-cov-html":"lab -vL -t 100 -r html"},"repository":{"type":"git","url":"git+https://github.com/cospired/hapi-plugin-mysql-promise.git"},"keywords":["hapi","mysql","mysql2","promise","plugin"],"contributors":[{"name":"Adri Van Houdt","email":"adri.van.houdt@gmail.com"},{"name":"Jan Schmidle","email":"jan@cospired.com"},{"name":"Dirk Haage"}],"license":"MIT","bugs":{"url":"https://github.com/cospired/hapi-plugin-mysql-promise/issues"},"homepage":"https://github.com/cospired/hapi-plugin-mysql-promise","dependencies":{"hoek":"^4.2.1","mysql2":"^1.7.0"},"peerDependencies":{"hapi":">=9.x.x"},"engines":{"node":">=8.0.0"},"devDependencies":{"@hapi/code":"^6.0.0","@hapi/lab":"^24.0.0","hapi":"16.x.x"},"gitHead":"d1f219ae1856ef7935558a71d7de836f4d6ae5ad","_id":"@cospired/hapi-plugin-mysql-promise@2.0.1","_nodeVersion":"15.8.0","_npmVersion":"7.5.1","dist":{"integrity":"sha512-2WYjabFIKnWbHXr05lpkxM+daRXGh3ejojUmULEJ70RWQ8tkrx0hNnaYBnvJ9ny4UZz/k9s09tj/2sCfutxEsw==","shasum":"016b74bf3b8261d7a292e643c7467a937ef68318","tarball":"https://registry.npmjs.org/@cospired/hapi-plugin-mysql-promise/-/hapi-plugin-mysql-promise-2.0.1.tgz","fileCount":6,"unpackedSize":22065,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgWIudCRA9TVsSAnZWagAAbuAP/0WX5UkZEExHOGa7IrD+\nGv2ficUA+yj3cReqrF7+RmWyFM6XCPGKgTzcMSfwQc05oPjhN6UCon4tOi0+\nFvD5PIZ2Hp9bimuEl+0XLBjbgUH52fYCAkmK3VTQukZre0eY68qtoJxRY3ha\n6k+wH20VEGl/DGDCqFUNuBeSfcQGsTFC87rjwTFP+6NkIKZG4nlSsBhXIEHY\nKugK9AZKn5c4ENl4AbYmyobfsmDFlvH7wCGrvDlXaUxp9hBxb1jj/z9x6cRT\n6bUccw1VLJHCj+UvB/olicQnb2UopoRnLBTwTJGPnlK/qflALkDjr2my76qm\ncqggxIvnL6PtFoiowfQmpmDj4EeeLYsoAeMpKcfu7MvwSoaTfdvvQbsZwmSF\nDfDNs98GpkYOtmZNsby/DgNwYnMH+YaLtvad9NvlmMGDhbmsHxzNcUf/MIpA\nQoLbI2AyLancWhpuB8exRXJxU7hMxVkSsavMSprK+gIlN15rZczsgYYlqAMU\nbrj2YTewO8obRVFj5R4JbvKxkeE/bGMqlULEfznGDtjS/1e6u3NlTNJV7ZMd\naN5R4Brjycd9vyUKLpJDnMyfycm4FFbJPrlbQGEUnOk4wPOsdd5vlOlTwi12\nWPB8zIw4e7J6cMwr6XX0GVEeKvNTudLRDY6J55s3dCcIYTpn1UGoGzQGEq0x\nWCgt\r\n=xLhc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCiP7kZ0rnyf38z1xRRLUUvpy3o8AvpoPEfoi0jfPM/mQIgB+hl7eRYEcViymOJqD6ZdhrR7aCkcZnUHKICs6SUqh0="}]},"_npmUser":{"name":"e110c0","email":"dirk+npm@cospired.com"},"directories":{},"maintainers":[{"name":"e110c0","email":"dirk+npm@cospired.com"},{"name":"bitcloud","email":"jan@jschmidle.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hapi-plugin-mysql-promise_2.0.1_1616415645296_0.3395173334633521"},"_hasShrinkwrap":false},"2.1.0":{"name":"@cospired/hapi-plugin-mysql-promise","version":"2.1.0","description":"Hapi plugin for MySQL","main":"lib/index.js","private":false,"scripts":{"test":"lab -v -t 100","test-cov-html":"lab -vL -t 100 -r html"},"repository":{"type":"git","url":"git+https://github.com/cospired/hapi-plugin-mysql-promise.git"},"keywords":["hapi","mysql","mysql2","promise","plugin"],"contributors":[{"name":"Adri Van Houdt","email":"adri.van.houdt@gmail.com"},{"name":"Jan Schmidle","email":"jan@cospired.com"},{"name":"Dirk Haage"}],"license":"MIT","bugs":{"url":"https://github.com/cospired/hapi-plugin-mysql-promise/issues"},"homepage":"https://github.com/cospired/hapi-plugin-mysql-promise","dependencies":{"hoek":"^4.2.1","mysql2":"^2.3.3"},"peerDependencies":{"hapi":">=9.x.x"},"engines":{"node":">=8.0.0"},"devDependencies":{"@hapi/code":"^6.0.0","@hapi/lab":"^24.0.0","hapi":"16.x.x"},"gitHead":"7ef5818a1f0f3e66754629a87db284e42fe3e7d6","_id":"@cospired/hapi-plugin-mysql-promise@2.1.0","_nodeVersion":"18.7.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-+MLaXJtANk7BYTYBGTu4Sl7sd/PGhg4x3D/AGqbqpfJdourj8b2rfoAZ7DdzPitesL832vheKqmPEcT2Gs2dHg==","shasum":"65d4a6af8c1066dd1a3e7c3055b235a911a5c7ce","tarball":"https://registry.npmjs.org/@cospired/hapi-plugin-mysql-promise/-/hapi-plugin-mysql-promise-2.1.0.tgz","fileCount":6,"unpackedSize":22065,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDTy/JuBj2RdNU0y5kNehjqtE6k44q0q0kjifhAwqHT/wIhAMiwjDxJCLx+K98ZPjhmrEJZSXs18oNFk+X+CrkaPl3B"}]},"_npmUser":{"name":"e110c0","email":"dirk+npm@cospired.com"},"directories":{},"maintainers":[{"name":"e110c0","email":"dirk+npm@cospired.com"},{"name":"bitcloud","email":"jan@jschmidle.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hapi-plugin-mysql-promise_2.1.0_1705151686933_0.18198504376010116"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-09T17:55:01.687Z","1.0.0":"2018-03-09T17:55:01.866Z","modified":"2024-01-13T13:14:47.371Z","2.0.0":"2018-10-10T13:51:52.131Z","2.0.1":"2021-03-22T12:20:45.476Z","2.1.0":"2024-01-13T13:14:47.159Z"},"maintainers":[{"name":"e110c0","email":"dirk+npm@cospired.com"},{"name":"bitcloud","email":"jan@jschmidle.org"}],"description":"Hapi plugin for MySQL","homepage":"https://github.com/cospired/hapi-plugin-mysql-promise","keywords":["hapi","mysql","mysql2","promise","plugin"],"repository":{"type":"git","url":"git+https://github.com/cospired/hapi-plugin-mysql-promise.git"},"contributors":[{"name":"Adri Van Houdt","email":"adri.van.houdt@gmail.com"},{"name":"Jan Schmidle","email":"jan@cospired.com"},{"name":"Dirk Haage"}],"bugs":{"url":"https://github.com/cospired/hapi-plugin-mysql-promise/issues"},"license":"MIT","readme":"# hapi-plugin-mysql-promise [![Build Status](https://travis-ci.org/cospired/hapi-plugin-mysql-promise.svg?branch=master)](https://travis-ci.org/cospired/hapi-plugin-mysql-promise)\n\n> hapi plugin for MySQL\n\nbased on [hapi-plugin-mysql](https://github.com/Salesflare/hapi-plugin-mysql) using [mysql2](https://github.com/sidorares/node-mysql2) and promises. As a side effect, this also supports JSON fields.\n\n## What\n\nAttaches a MySQL connection from a pool to every request. We are using `mysql2/promise` here to provide promisified version of the mysql connection.\n\n## How\n\nVia `request.app.db`.\nYou can also manually get a connection from the server via `server.getDb(function (err, connection) {})`.\n\n```javascript\nserver.register({\n    register: require('hapi-plugin-mysql'),\n    options: {\n        host: \"localhost\",\n        user: \"root\",\n        password: \"\"\n    }\n}, function (err) {\n\n    if (err) console.log(err);\n    ...\n});\n\nserver.route({\n    method: 'GET',\n    path: '/',\n    handler: function (request, reply) {\n\n        request.app.db.query(...)\n            .then((result) => reply(result))\n            .catch((err) => reply(err));\n    }\n});\n```\n\nThe options are the same options you can pass onto the `mysql2` lib for making a connection. See <https://www.npmjs.com/package/mysql2> for more info on the `mysql2` lib itself.\n\nThe keyword `db` is used because `connection` is used by `hapi` and might cause confusion/collision.\n\nIf you want more manual control or you want to use the same pool outside of the hapi part of your server\nyou can initialize the pool before the plugin registration by calling `require('hapi-plugin-mysql-promise').init(options, callback)` and then call `require('hapi-plugin-mysql-promise').getConnection` to get a connection from the pool.\nIf you still want to register the plugin (to get all the goodies) just don't pass any options to the plugin registration\nand it will use the same pool as first created.\nTo manually stop the pool call `require('hapi-plugin-mysql-promise').stop`.\nSee the tests for more granular use cases.\n\n## Catches\n\n- The releasing of the connection is handled on the `tail` event of the server. If you have handlers that reply early, with `reply.file()` for example, be sure to register a `tail` event and use that as callback.\n- Transactions are no longer a part of this plugin and should be handled (with care) in your code\n\n## Testing\n\n- 100% code coverage!\n- See `.travis.yml` and the tests for more info.\n\n## Changelog\n\nSee the [releases](https://github.com/cospired/hapi-plugin-mysql-promise/releases) page\n","readmeFilename":"README.md"}