Node.js using the Express framework with a React client application using MySQL to log the user in with passport with the passport-local strategy using a username and password.
My intentions creating this repository was to learn passport, as well as create a good amount of example code for others to help them create a successful user login system.
App Heroku hosted application View here: Passport-mern
Currently to run the application you will need to:
- Clone the repository locally
git clone https://github.com/Vincent440/passport-mern-sql.git- Create a
.envFile and store all the database connection information, Or any other environment variables that will change depending on where the application is hosted.
# Port to host application on.
PORT=3001
# Name of the mysql database you will be connecting to.
DB_NAME=mernpassportexample
# Host name for connecting to MySQL database
DB_HOST=hostname
#Port to connect to MySQL database
DB_PORT=3306
# User for connecting to MySQL database
DB_USER=userstringhere
# Password for connecting to MySQL database
DB_PASSWORD=passwordstringhere
- Run npm install commands to pull in the required packages:
npm install- Run the Database schema.sql to set up the database structure.
passport-mern-sql/config/schema.sql
- Run the Database seeds.sql file
passport-mern-sql/config/seeds.sql
Then you should be all set to start making changes to the application.
In order to deploy this application:
you will need to ensure have a mysql database attached to your server. The way this application is set up the .env variables will need to match how the local database .env variables are set up.
I used Heroku to deploy my application. to do the same you will need to:
- Have a Heroku account or create one.
- assuming you have an account. log in to the Heroku website.
- Create a new app and name it whatever you would like to match your applications initial Heroku url.
- Open
your application namefrom the dashboard on Heroku's website and selectDeploy - Select
Githuband login to Github to connect your account to Heroku - After succesfully connecting to Github connect the app to the github repository
- Select the Github account you are using and search for the repository using the search box provided.
- If you searched successfully you will see the repository you are looking for and have a Connect button.
- After pressing Connect you have the option to either select a branch and setup automatic deployments or manually deploy whenever you want to test your latest build in a branch. up to you.
-
Question? Open a Ticket here
-
Issue? Open a Ticket here
- Please leave a brief description
- Details surrounding the problem
- Attempts you took to fix it.
- OS you are using.