This boilerplate may be used as a starting point for building a full-stack app with Handlebars, Express, and Sequelize/MySQL. This boilerplate if configured for easy deployment on Heroku with JawsDB MySQL add-on.
- Run
npm i
. - You will need an existing MySQL database.
- Create
.env
file with MySQL credentials for local development and a SECRET. Refer to .env.EXAMPLE - Run
npm start
to start the app.
This boilerplate includes nodemon. Run npm run watch
to start the server in watch mode during development.
express-session and connect-session-sequelize are used for session management. Configure cookies and sessions in config/session.js
Passwords are hashed using bcrypt. Middleware for protected routes redirects to /login
. This can be modified by updating util/withAuth.js.
Handlebars.js and express-handlebars are used for rendering templates.
You can add your own custom helper functions by exporting them from util/helpers.js.
ESLint and Prettier are included for enforcing consistent code quality and format. The default configuration includes the ESLint recommended plugin, the Prettier plugin, plus a couple of additional rules. Modify .eslintrc.js to customize the rules.
Sign up for an Heroku account and install the Heroku CLI.
The app must be setup using Git for version control in order to deploy on Heroku following this guide. Be sure to initialize Git before proceeding if you did not initially create this project by using the template repo.
The code for this boilerplate is pre-configured to deploy to Heroku and connect to the JAWS DB add-on for MySQL. In order to deploy, you must provision the JAWS DB add-on.
IMPORTANT: Payment info. must be provided in order to use the JawsDB MySQL add-on. The service is currently free with limitations. (as of 11/2/2021) However, you must provide a credit card to use the service.
-
Create a Heroku app in the command line.
heroku create <optionally-provide an app name>
-
Provision the JawsDB MySQL add-on with the free pricing plan.
heroku addons:create jawsdb:kitefin
-
Add environmental variables to the heroku config. The boilerplate uses
SECRET
to sign the session id cookie. Use a tool to generate a long randomized string for this value. (e.g.hsKVlvYcC5b#Fw1FS*qz
) AddSECRET
to config by runningheroku config:set SECRET=<your long random secret>
. -
Use the same command to add any other environmental variables required for your app to function. (
heroku config:set <name>=<value>
) -
Deploy the app by running
git push heroku main
. (Use the command again to deploy updates.) -
Open your app in the browser with
heroku open
.
Running heroku run npm run seed
will run the seed script in Heroku if your
seeds are required for production.