npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-mysql-boilerplate

v1.0.7

Published

node-mysql-boilerplate

Readme

Node with MySQL BoilerPlate/Framework

A simple and structured way boilerplate for Node with MySQL, equipped with MVC layer model with basic validation of schema and common error handler, authentication and easily pluggable code base.

This Boilerplate have a basic CRUD operation with MySQL, authetication of API endpoint with JWT Token and Validation of request and response of each route. It contained a documentation folder which contain swagger documentation easy for front-end developer to use and understand. It contained Pm2 which helps to restart, reload and monitor application in production, provides zero downtime availability. It has Nodemailer which will send email. It has bcrypt module which will encrypt password and make it more secure. It contain Artillery for load testing.

PreRequisite

Used Packages

1. MYSQL

 npm install mysql 

2. Express

npm install express 

3. Ajv

npm install ajv 

4. JWT

npm install jsonwebtoken 

5. Nodemon

npm install nodemon 

6. pm2

npm install pm2  
  • pm2 will watch, restart and reload application if any crashes happen, it provide cluster mode as well as zero downtime failure. know more about pm2
  • To Know more about pm2 check here

7. nodemailer

npm install nodemailer  

8. artillery

npm install artillery  
  • artillery will perform load testing and gives logs, how sustainable your Api to perform number of request in per second .know more about artillery
  • To Know more about artillery check here

9. bcrypt

npm install bcrypt  

Get Started

  1. $ git clone https://github.com/yug95/node-mysql.git
  2. $ npm install
  3. Launch Enviornment:
    • $ node app.js or nodemon app.js
  4. In Cluster mode with the help of pm2 [optional step]:
    • $ pm2 start app.js or pm2 start app.js -i <no of instances>
  5. Open in browser:
    • open http://localhost:9890

API Usage

  1. login route - http://localhost:9890/api/login
    • pass json object contain username and password.
  2. other crud route are in secureApi - localhost:9890/secureApi/user.
    • In all GET, PUT, DELETE and POST request pass token in header which you get in login response.

Example object for login request -

{
    "username":"test",
    "password":"testpass"
}

For Other Crud request -

{
   "name":"username",
   "age:11,
   "state":"statename",
   "country":"countryname"
}

Note: You have to pass token for each request as header which youi will get in login response.

Features

  • To perform basic operation all Create, Fetch, Delete and Update functionality.
  • Used Express framework to obtain required operations.
  • Used Express router to route endpoint path.
  • Used JWT Token for security and authentication of API.
  • MVC structure in which Route, Service and Model layer.
  • Used AJV as schema validator which validate request and response schema.
  • Used Connection Pooling which lead to reduce number of conncetion at any point of time and reduce stress in DB which leads to better availability and Performance of DB.
  • Used common error structure format for all type of error throwing in Application.
  • Includes documents folder which contain swagger representation both in JSON and HTML, which will help front-end developer for better understanding.
  • Pm2 a process manager which help to watch, reload, restart and monitor with load balancer in each and every activity.
  • nodemailer is used to send mail over SMTP. as for i now used for sending mail if error comes.
  • bcrypt is used to encrypt your password through salt and hashing technique and which won't store password as plain text in database.
  • artillery is used to perform load testing which will check sustainibility of your API at high traffic.

Swagger Related task

  1. How to Open Swagger -
  2. Go to File and import file option, import JSON file present in document folder.
  3. To Download HTML file of particular JSON
    • Go to Generate Client option and html2 option it will download html file.
  4. Know more about Swagger Check here

Artillery Run

  1. First go to /loadtest folder
  2. you can use artillery in 2 way :-
    • by hardcoding data in yml file.
    • getting data by .csv file.
  3. For option 1 run - artillery run hello.yml
  4. For option 2 first get CSV file with data.
  5. define path in yml file and run example as i Did :- artillery run hellocsv.yml