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).
- GOOGLE_API_TOKEN
- connection string of mongodb
The dev environment is using concurrently.
-
install
concurrentlynpm install -D concurrently -
change image uploads path (backend) from
uploads/imagestobackend/uploads/images -
install modules of frontend
cd frontend npm install -
install modules of backend
cd backend npm install -
add
.envin root folder (this is only for dev) -
add
.gitignorein root folder -
add and modify
package.jsonin root folder"scripts": { "dev": "concurrently \"npm start --prefix frontend\" \"nodemon backend/app.js\"", }
-
run dev envoriment
mpn run dev
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- modify
package.jsonin 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" }
- modify api cal url from
http://localhost:5000to url ofherokuapplication - modify
backend/app.js, add the followingapp.use(express.static(path.resolve(__dirname, '../frontend/build'))); app.get('*', (req, res) => { res.sendFile(path.resolve(__dirname, '../frontend/build', 'index.html')); });
- change port to 443
- add environment variables (mongodb link and goole map api)
- set image upload folder to AWS S3 bucket (not done)
other deployment option: docker-compose