This is an article where the main content is about how to install Express MyConnection package or module. It is a package or module which is added for special reason. The main reason is for the express framework powering a web-based application have the ability to connect to MySQL Database. Based on the description given in this link where the actual blog of the person created it. Based on the explanation on the person created which is written on the blog of the person himself, he mentioned that he had alreadly created the super simple middleware module express-myconnection that provides a consistent API for MySQL connections during the request/response life cycle. It is also stated that it supports three different strategies of managing db connections: single
for a singleton connection on an app instance level, pool
based connections, and a new connection per each request
. Another feature described is that it is also capable of auto releasing/closing connections if configured with either the pool
or request
strategy. But aside of that, the installation process itself is actually quite simple when it is actually involving npm tool. The process taken is shown as follows :
- Execute the command npm install -save express-myconnection as shown below :
user@hostname:~/nodejs/apps$ npm install --save express-mycnnection [email protected] /home/user/nodejs/apps └── [email protected] user@hostname:~/nodejs/apps$
2. Check whether the entry of express-myconnection package or module has been inserted and it is defined in the package.json file. The actual content will show it has been inserted if the process in the previous step run smoothly. The following is the content of the file which is declaring the newly added package or module :
{ "name": "application-name", "version": "0.0.1", "private": true, "scripts": { "start": "nodejs ./bin/www" }, "dependencies": { "body-parser": "~1.0.0", "cookie-parser": "~1.0.1", "debug": "~0.7.4", "express": "~4.0.0", "express-myconnection": "^1.0.4", "jade": "~1.3.0", "morgan": "~1.0.0", "mysql": "^2.15.0", "static-favicon": "~1.0.0" } }
As shown in the above output, the entry ‘express-myconnection’ is clearly defined in the ‘dependencies’ section.
3. Prove it further by executing the command ‘npm list’ as shown below :
user@hostname:~/nodejs/apps$ npm list | grep express-myconnection ├── [email protected] ... user@hostname:~/nodejs/apps$
One thought on “How to Install Express MyConnection Package or Module for Web-based Application powered by Express Framework in Node.js”