This project is a barebones clone of Facebook, allowing users to sign up, log in, create posts, view posts and favourite posts from other users. It is built using the MERN stack (MongoDB, Express, React, Node.js). It was built in a team of 5 over the course of 2 weeks in an agile environment, using a Kanban board to track progress.
Navigate to the frontend file and install the dependencies
cd frontend
npm i
Navigate to the api file and install the dependencies
cd api
npm i
-
Start the server application (in the
apidirectory)Note the use of an environment variable for the JWT secret
; cd api ; JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm start -
Start the front end application (in the
frontenddirectory)
In a new terminal session...
; cd frontend
; npm start
You should now be able to open your browser and go to http://localhost:3000/signup to create a new user.
Then, after signing up, you should be able to log in by going to http://localhost:3000/login.
After logging in, you won't see much but you can create posts using PostMan and they should then show up in the browser if you refresh the page.
The automated tests run by sending actual HTTP requests to the API. Therefore, before anything, you'll need to start the backend server in test mode (so that it connects to the test DB).
Note the use of an environment variable for the JWT secret
# Make sure you're in the api directory
; cd api
; JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm run start:testYou should leave this running in a terminal.
Then, you can either run tests for the backend or the frontend following the steps below.
Run the tests in a new terminal session:
# Make sure you're in the api directory
; cd api
; JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm run testStart the front end in a new terminal session
# Make sure you're in the frontend directory
; cd frontend
; JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm startThen run the tests in a new terminal session
# Make sure you're in the frontend directory
; cd frontend
; JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm run testSome people occasionally experience MongoDB connection errors when running the tests or trying to use the application. Here are some tips which might help resolve such issues.
- Check that MongoDB is installed using
mongo --version - Check that it's running using
brew services list
If you have issues that are not resolved by these tips, please reach out to a coach and, once the issue is resolved, we can add a new tip!