In this group project we were tasked with taking on an existing codebase for a social media app "Acebook" and extending and improving on both the frontend and backend of the app to include new features.
A significant part of the work included familiairising ourselves with the codebase we inherited and learning and implementing new languages and frameworks within a timeframe of two weeks.
We also focused heavily on adding styling to make the app more interactive and "user friendly".
Trello Board can be found here
-
Fork this repository
-
Clone your fork to your local machine
-
Install Node.js dependencies for both the
frontend
andapi
directories.cd api npm install cd ../frontend npm install
-
Install an ESLint plugin for your editor. For example:
linter-eslint
for Atom. -
Install MongoDB
brew tap mongodb/brew brew install [email protected]
-
Start MongoDB
brew services start [email protected]
-
Setup environment variables
Copy the .env.example file and rename .env
update the relevent variable values ensure the JWT secret is the same on the frontend as the api
-
Start the server application (in the
api
directory)cd api npm run dev
-
Start the front end application (in the
frontend
directory)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).
cd api
JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm run start:test
You 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 test
Start the front end in a new terminal session
# Make sure you're in the frontend directory
cd frontend
JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm start
Then run the tests in a new terminal session
# Make sure you're in the frontend directory
cd frontend
JWT_SECRET=f6d278bb34e1d0e146a80b16ec254c05 npm run test
Some 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