Here's your fixed and polished README file:
This is the backend of a social media application built with Node.js, Express, and MongoDB. It handles user authentication, post creation, and post interaction.
Follow these steps to set up the project locally for development and testing.
Ensure you have the following installed:
- Clone the repository:
git clone <repository-url>
- Navigate to the project directory:
cd <project-folder>
- Install dependencies:
npm install
- Create a
.env
file in the root directory and add the following:MONGODB_URL=your_mongodb_url JWT_SECRET=your_jwt_secret
- Start the server:
npm start
-
POST /api/user/new/user
- Create a new user.
- Request Body:
{ email, username, password, profile }
- Response:
{ user, accessToken }
-
GET /api/user/login
- Log in a user.
- Request Body:
{ email, password }
- Response:
{ user, accessToken }
-
PUT /api/user/:id/follow
- Follow or unfollow a user.
- Request Body:
{ user }
- Response:
"User has been followed"
or"User has been unfollowed"
-
GET /api/user/flw/:id
- Get posts from followed users.
- Response: Array of posts.
-
GET /api/user/all/user/:id
- Get all users except those followed by the current user.
- Response: Array of users.
-
PUT /api/user/update/password/:id
- Update user password.
- Request Body:
{ oldPassword, newPassword, confirmPassword }
- Response:
"Password has been updated"
-
GET /api/user/get/search/user
- Search for users.
- Query Params:
keyword
- Response: Array of users.
-
GET /api/user/explore
- Get all posts sorted by weight.
- Response: Array of posts.
-
POST /api/post/new/post
- Create a new post.
- Request Body:
{ title, image }
- Response: Post object.
-
POST /api/post/all/post/by/user
- Get all posts by the current user.
- Response: Array of posts.
-
PUT /api/post/:id/like
- Like or dislike a post.
- Response:
"Post liked"
or"Post disliked"
-
PUT /api/post/comment/post
- Add a comment to a post.
- Request Body:
{ comment, postId, profile }
- Response: Post object.