Skip to content

phillipDarby/react-mysql-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MySQL React Node Express with Enzyme and Jest

Description

This starter template is using create-react-app and is using the MERN stack. Not Mongodb but MySQL.

Getting Started

Start by cloning the repo

git clone https://github.com/phillipDarby/react-mysql-boilerplate.git MyAppName

There are two package.json files that will need to be used to install dependencies. One in the root directory and one in the client directory.

Using NPM

This template is already set up to use NPM. Just update your package.json scripts in the root directory to:

  "scripts": {
    "start": "node server/server.js",
    "heroku-postbuild": "cd client && npm install --only=dev && npm install && npm run build",
    "server": "nodemon server/server.js",
    "client": "npm run start --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  },

To install dependencies, inside the root and client directory run

npm install

Once the dependencies have been installed from both directories, you can start the template from the root directory by running

npm run dev

Using Redux

To use redux:

add action-type to ./constants/action-types.js

add reducer to ./reducers/index.js

add action to ./actions/index.js

you should not need to modify the store at ./store.index.js unless you are adding more middleware.

for more detailed tutorial visit https://www.valentinog.com/blog/redux/

Configuring dev environment keys

Inside the server/config directory you can add a dev.js file to hold your db information or things like API keys while you develop. This repo is already set to .gitignore dev.js but if you name your file something different just don't forget to update your .gitignore.

Heroku Deploy Option

There is a heroku-postbuild script included in the template if you choose to deploy to Heroku. This article by Dave Ceddia covers the reasoning pretty well. But basically it tells heroku to install the react-scripts needed to build the React app. By default the react-scripts are not installed in production.

About

The starting point for a new react-mysql stack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published