A boilerplate for Node.js web applications. This boilerplate gives the basic stucture of application start with while bundling enough useful features so as to remove all those redundant tasks that can derail a project before it even really gets started. This boilerplate users Express with sequelize as ORM and MySQL as database.
NodeJs
NPM
MySQL
- Clone the repository with
git clone https://github.com/mangya/node-express-mysql-boilerplate.git <your_project_folder_name>
- Change directory to your project folder
cd <your_project_folder_name>
- Install the dependencies with
npm install
- Create database in MySQL.
- Update the your database name and credentials in the
.env
file. - Run the application with
npm start
(MySQL service should be up and running). - Access
http://localhost:3000
and you're ready to go!
.
├── app/
│ ├── controllers/ # Controllers
│ ├── middlewares/ # Middlewares
│ ├── models/ # Express database models
├── config/
├── public/
│ ├── css/ # Stylesheets
│ ├── js/
│ ├── fonts/
│ ├── images/
├── .env # API keys, passwords, and other sensitive information
├── routes/ # Route definitions
├── views/ # All view files
├── index.js # Express application
└── package.json # NPM Dependencies and scripts
- nodemon — tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
- bcryptjs — encryption library to hash a password
- body-parser — Node.js body parsing middleware. Parse incoming request bodies in a middleware before your handlers, available under the req.body property.
- express-flash — middleware to store flash messages in the session.
- connect-session-sequelize — SQL session store using Sequelize.js
- csurf — Middleware for CSRF token creation and validation. Requires session middleware to be initialized first. We have used
express-session
- dotenv — module to load environment variables from a .env file
- express — web application framework for node
- express-handlebars — Template engine
- express-session — Module to create a session middleware. Required for
csurf
. - validator — A library of string validators and sanitizers.
- mysql2 — MySQL client for Node.js. Required for Sequelize.
- sequelize — Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.
This boilerplate is open to suggestions and contributions, documentation contributions are also welcome! 😊