Starter code for Social Media with both front/backend and working authentication system for user registration, log in, and log out.
- Download the .zip file of the source code to your computer. (If you choose to clone the repository, make sure to remove the
.gitfolder from the root directory). - Unzip and open the
SocialMedia_StarterCode-FullStackfolder in Visual Studio Code.
- Change directory into the backend folder:
cd backendfrom the Integrated Terminal in Visual Studio Code - Run the
npm installcommand in your terminal to install dependencies from thepackage.jsonfile - Create a
.envfile in thebackendfolder (it should rest at the same level in the directory as theindex.jsfile) - Inside of the
.envfile, create three variables:MONGODB_CONNECTION_STRING,JWT_SECRET,PORT - The
MONGODB_CONNECTION_STRINGshould be set to your connection string from MongoDb Atlas JWT_SECRETcan be a string of random numbers, letters, and characters - make it at least 32 characters long- Set the
PORTvariable to a four digit port, anything but the number "3000" - Save and run the
npm startcommand to test your server is running correctly - Import the
Social Media Starter.postman_collection.jsonfile into Postman. For the URL of each request, make sure to change the port number to the one you set in your.envfile. - Be sure to watch the walkthrough video for how to run each test in Postman to verify your server is set up correctly!
‼️ NOTE: BE SURE TO .gitignore the.envfile in your backend before committing to GitHub!
- Change directory into the frontend folder:
cd frontend. You may need to run thecd ..command to get back to your root directory first. - Run the
npm installcommand to install Node dependencies. - Inside of
src/context/AuthContext.js, find theBASE_URLvariable (line 11) and make sure the port number of the URL matches the port number you set up in your backend.