MySQL-Express-React-Node app with custom webpack config, docker, CI config, test suites, and JWT authentication stored as cookie
- Staging environment: https://mernolithic-sql-staging.herokuapp.com/
- Production environment: https://mernolithic-sql-production.herokuapp.com/
-
Update project name and urls for github in package.json
- Name
- repository: url
- bugs: url
- homepage: url
-
Update app name/urls in:
- ~/cypress.staging.json and ~/cypress.production.json
- App title in ~/frontend/src/index.html
-
Create
.env
file in project root with following propertiesMYSQL_PASSWORD= "12345678" MYSQL_HOST= "localhost" AUTH_SECRET=your_auth_secret_key ADMIN_USER_PWD=admin_password USER_PWD="12345678" FORCE_SYNC= false
-
Run
yarn install
from the project root to install project dependencies -
cd backend
and runyarn install
to install backend server dependencies -
cd frontend
and runyarn install
to install frontend React dependencies -
Run
initialize.sh
command from the project root to automatically create staging and production Heroku remotes with MySql databases provisioned and deployed -
You can run the application locally by running command
yarn start-dev
from the project root to start the server on localhost:8080, and thencd frontend
in another terminal and runyarn start-dev
to start the Webpack dev server for the React frontend which you can view at localhost:8081 this has hot reloading for easier development -
To setup circleci, first go to your dashboard on circleci.com. Click "Add Project" and choose the repo for your project. Then select "Build Now" to start building the project. Update the "working_directory" variable at the top of ~/.circleci/config.yml to match your repo name as well
-
to rename your Heroku staging and production apps, use command
heroku apps:rename --remote staging newname
. Insert the desired name of the app instead of "newname" and you can select the "production" remote instead of staging to rename produciton as well. Be sure to update the database names in mysql ~/backend/config/config.js to match your app name too
-
After running the
initialize.sh
script, you will have a Staging and a Production environment already deployed to Heroku. -
To deploy whatever is on your git master branch again later, use command
git push staging master
orgit push production master
depending on which environment you want to deploy
You can easily run tests against your different environments with these commands. After the tests complete, your browser will automatically open with the test results report. If you ran in the local environment, it will also open a fullstack coverage report of your entire project.
Local
yarn test:local:test-and-report
Staging
yarn test:staging:test-and-report
Production
yarn test:production:test-and-report
- Run tests and generate a test report using mochawesome. From the root, use command
test:create-reports
which will run allcypress/integration/*-spec.js
files. Then you can open thecypress/reports/integration/public/report.html
file to view the test report in the browser
- run tests using cypress.io. From the root, use command
yarn dev:coverage
which will open the test runner. Then select "run all specs" to run all the tests. Then you can open thecoverage/lcov-report/index.html
file to view the fullstack code coverage report in the browser npx nyc report --reporter=text-summary
will print out a coverage summary in the console
Starting with React/Webpack/Babel from scratch - https://www.valentinog.com/blog/babel/ Using CSS Grids - https://css-tricks.com/snippets/css/complete-guide-grid/ Help with SQL associations and file seperation - sequelize/sequelize#4578
- Sequelize Queries
- Sequelize Associations Part 1
- Sequelize Association Part 2
- Sequelize Migrations
- bcrypt (NPM)
- Awesome video on cypress fullstack code coverage
- https://webpack.js.org/guides/production/ use this to split webpack config
- have to remove codeCoverage url from cypress.json for tests to run in cI