Welcome to the login-app project, inspired by StackUp Backend ExpressJS part II campaign! This README provides step-by-step instructions on how to set up and run the project after cloning or downloading it from the GitHub repository.
- Prerequisites
- Installation
- Environment Variables
- Running the Server
- Project Structure
- Troubleshooting
Before you begin, ensure you have met the following requirements:
- You have installed Node.js and npm. You can download them from Node.js.
- You have a MongoDB Atlas account. You can sign up for free at MongoDB Atlas.
Follow these steps to get your development environment set up:
-
Clone the repository:
git clone https://github.com/your-username/StackUp-BackEnd-ExpressJS-Part-II.git cd StackUp-BackEnd-ExpressJS-Part-II -
Navigate to the project directory:
cd login-app -
Install the dependencies:
npm install
You need to set up your environment variables to connect to your MongoDB database and configure other settings.
-
Create a
.envfile in the root of the project directory:touch .env
-
Add the following variables to your
.envfile:db_connection="your_mongodb_connection_string" PORT=3001 SESSION_SECRET='your_session_secret'
Replace your_mongodb_connection_string with the connection string from your MongoDB Atlas account, and your_session_secret with a secret string for your session.
-
Start the server:
node app.js
-
Access the application:
- Open your browser and go to
http://localhost:3001.
- Open your browser and go to
Here is an overview of the project's structure:
StackUp-BackEnd-ExpressJS-Part-II/
├── login-app/
│ ├── models/
│ │ └── UserModel.js
│ ├── public/
│ │ └── styles.css
│ ├── views/
│ │ ├── dashboard.ejs
│ │ ├── login.ejs
│ │ ├── register.ejs
│ │ └── welcome.ejs
│ ├── .env
│ ├── app.js
│ ├── package.json
│ └── package-lock.json
-
Common Issues:
- Ensure MongoDB connection string is correct and your IP is whitelisted in MongoDB Atlas.
- Verify that Node.js and npm are installed correctly.
- Check the environment variables in the
.envfile for any missing or incorrect values.
-
Debugging:
- Use
console.logstatements to debug issues. - Check the terminal for server logs and errors.
- Ensure all dependencies are installed correctly by running
npm install.
- Use
-
Database Connection Issues:
- Make sure your MongoDB Atlas cluster is running.
- Check if your database credentials in the
.envfile are correct.
If you encounter any issues or have any questions, feel free to open an issue on the GitHub repository. Happy coding!