This is a backend API for a social media platform built with Node.js, Express.js, and MongoDB. The API allows users to sign up, log in, create posts, like posts, follow and unfollow other users, and get a list of posts from users they are following.
- Clone the repository:
https://github.com/Ashu-14-oct/social-media-api.git
- Install dependencies:
npm install
- Create a
.env
file in the root directory and add your secret key - Start the server:
npm start
The API has the following endpoints:
Sign up a new user with a name, email, and password. Returns a JWT token.
Log in an existing user with an email and password. Returns a JWT token.
Create a new post with a title and content.
Get a single post by ID.
Follow a user by ID.
Unfollow a user by ID.
Get a list of posts by a user.
Get a list of users that a user is following.
Get a list of users that follow a user.
POST /sign-up { "name": "John Doe", "email": "johndoe@example.com", "password": "password" }
POST /sign-in { "email": "johndoe@example.com", "password": "password" }
POST /api/posts { "content": "Hello, world!" }
POST /follow/607f1d38f7ed310fd432dbaf
POST /unfollow/607f1d38f7ed310fd432dbaf
This project is licensed under the MIT License - see the LICENSE file for details.