NewsSphere Backend is the server-side component of the NewsSphere project, responsible for handling data related to news articles, user accounts, and interactions.
- User authentication and authorization
- CRUD operations for news articles
- User-specific saved articles
- RESTful API endpoints
- Error handling and validation
-
Clone the repository:
git clone https://github.com/Harshdev625/newssphere-backend cd newssphere-backend
-
Install the required dependencies by running npm install:
npm install
-
Create a MongoDB Atlas account and set up a cluster. Here's how you can do it:
- Go to the MongoDB Atlas website: https://www.mongodb.com/cloud/atlas
- Sign up for an account if you don't have one, or log in if you do.
- Create a new project and cluster.
- Follow the prompts to configure your cluster settings, such as clouprovider and region.
- Once your cluster is created, you'll get a connection string. This will be used in your backend server.
-
Create a .env file in the root folder of the project and add the following environment variables:
MONGODB_URI=YOUR_CONNECTION_STRING
Replace YOUR_CONNECTION_STRING with the actual connection string you obtained from MongoDB Atlas.
-
Run the server using :
nodemon index.js
-
The backend server is now running on http://localhost:8080.
-
Open MongoDB Compass:
- Download and install MongoDB Compass: https://www.mongodb.com/try/download/compass
- Open MongoDB Compass.
- Connect to your MongoDB Atlas cluster using the connection string.
- You can now interact with your MongoDB database using the MongoDB Compass GUI.
Make sure to follow each step carefully and replace placeholders with actual values. This guide should help you set up your backend server and connect it to your MongoDB Atlas cluster using MongoDB Compass for database management.
Contributions to the NewsSphere Backend are welcome! If you encounter any bugs, or issues, or have ideas for improvements, please open an issue on the repository. Pull requests with enhancements are also appreciated.
- Node.js
- Express.js
- MongoDB Just so you know, the frontend repository NewsSphere needs to be set up and connected to this backend server for the complete functionality of the application.