Skip to content

dhuangca/mern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

The codes are based on a simple MERN application called “Our Places”.

Additional Features

  • enable users to add Place Type on the "Add Place" form
  • Add a new page to list all place post (pagination is included).

Environment Variables

  • GOOGLE_API_TOKEN
  • connection string of mongodb

Dev Environment (locally)

The dev environment is using concurrently.

  • install concurrently npm install -D concurrently

  • change image uploads path (backend) from uploads/images to backend/uploads/images

  • install modules of frontend

    cd frontend
    npm install
  • install modules of backend

    cd backend
    npm install
  • add .env in root folder (this is only for dev)

  • add .gitignore in root folder

  • add and modify package.json in root folder

    "scripts": {
      "dev": "concurrently \"npm start --prefix frontend\" \"nodemon backend/app.js\"",
      }
  • run dev envoriment mpn run dev

testing

testing is included with jest and @testing-library

example testing file: src/shared/components/FormElements/DropDown.test.js

test frontend:

cd frontend
npm run test

Deployment (heroku)

  1. modify package.json in root path
    "scripts": {
     "dev": "concurrently \"npm start --prefix frontend\" \"nodemon backend/app.js\"",
     "frontend": "cd frontend && npm install  && npm run build",
     "backend": "cd backend && npm install",
     "start": "node backend/app.js",
     "heroku-postbuild": "npm run frontend && npm run backend"
    }
  2. modify api cal url from http://localhost:5000 to url of heroku application
  3. modify backend/app.js, add the following
    app.use(express.static(path.resolve(__dirname, '../frontend/build')));
    app.get('*', (req, res) => {
      res.sendFile(path.resolve(__dirname, '../frontend/build', 'index.html'));
    });
  4. change port to 443
  5. add environment variables (mongodb link and goole map api)
  6. set image upload folder to AWS S3 bucket (not done)

other deployment option: docker-compose

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages