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.
npm install mysql
npm install express
npm install ajv
npm install jsonwebtoken
npm install nodemon
npm install pm2
npm install nodemailer
npm install artillery
npm install bcrypt
id,name,age,state,country
columns.$ git clone https://github.com/yug95/node-mysql.git
$ npm install
$ node app.js or nodemon app.js
$ pm2 start app.js or pm2 start app.js -i <no of instances>
http://localhost:9890
http://localhost:9890/api/signup
http://localhost:9890/api/login
localhost:9890/secureApi/user
.
token
in header which you get in login response.Example object for login request (body as JSON object) -
{
"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.
Create
, Fetch
, Delete
and Update
functionality.Route
, Service
and Model
layer.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
.File
and import file
option, import JSON
file present in document
folder.HTML
file of particular JSON
Generate Client
option and html2
option it will download html file./loadtest
folder.csv
file.artillery run hello.yml
artillery run hellocsv.yml