A social media API built with Node.js, Express.js, and MongoDB. This API is built for developers to use in their projects. It is not meant to be used as a standalone social media platform. This API is still in development and is not ready for production use.
- User authentication and authorization.
- CRUD operations for users, posts, and notifications.
- JWT-based authentication for secure API access.
- RESTful API design.
- Written in TypeScript for enhanced maintainability and type safety.
- Personal Chat
- Group Chat
- End-To-End Encryption in Chat
You can follow these instructions to get the project up and running on your local machine.
You need to have the following software installed on your computer:
-
Star the repository.
-
Clone this repository to your local machine using the following command:
git clone https://github.com/nixrajput/social-media-api-nodejs.git
-
Navigate to the project directory:
cd social-media-api-nodejs
-
Install the project dependencies:
If you're using npm:
npm install
If you're using pnpm:
pnpm install
If you're using Yarn:
yarn install
If you're using bun:
bun install
Before running the application, you need to configure the environment variables. Copy the .env.example
file to .env.local
and fill in the necessary values.
cp .env.example .env.local
Make sure you have a database configured and running. Update the database connection details in the .env.local
file.
Once the dependencies are installed and the configuration is set up, you can start the application by running:
npm run dev
#or
pnpm run dev
# or
yarn dev
# or
bun run dev
By default, the application will run on port 3000
. You can change the port by modifying the PORT
environment variable in the .env.local
file.
The API uses JWT (JSON Web Tokens) for authentication. To authenticate, send a POST request to /api/v2/auth/login
with a JSON payload containing the user's email and password.
{
"email": "[email protected]",
"password": "password"
}
If the credentials are valid, the API will respond with a JWT token, which should be included in subsequent requests as an Authorization header:
Authorization: Bearer <token>
- POST /api/v2/auth/register: Create a new account.
- POST /api/v2/auth/login: Login to the account.
- GET /api/v2/auth/me: Get profile details.
- GET /api/v2/post/create: Create a new post.
- GET /api/v2/post/feed: Get post feed.
This API can be deployed using various platforms such as Heroku, AWS, Google Cloud Platform, or your own server infrastructure. Here are some general steps to deploy the API:
-
Prepare your environment: Ensure that your deployment environment meets the requirements specified in the Prerequisites section.
-
Build the application: If necessary, build the TypeScript code into JavaScript. You can do this by running:
npm run build
or
yarn build
or
bun run build
-
Configure environment variables: Set up environment variables similar to how it's done in the local setup. Ensure that you provide appropriate values for your deployment environment.
-
Deploy the application: Deploy the built application to your chosen platform. Each platform may have its own deployment process. Refer to the documentation of your chosen platform for detailed instructions.
-
Start the application: Once deployed, start the application in your deployment environment. This might involve running a command similar to
npm start
oryarn start
, depending on your setup. -
Monitor the deployment: Monitor the deployed application for any issues. Make sure that it's running smoothly and handle any errors or performance issues as needed.
- Node.js
- Express.js
- Bun
- TypeScript
- MongoDB
If you would like to contribute to this project, feel free to fork the repository, make your changes, and submit a pull request. Please follow the guidelines in the CONTRIBUTING.md file.
This project is licensed under the MIT License - see the LICENSE file for details.
By sponsoring my efforts, you're not merely contributing to the development of my projects; you're investing in its growth and sustainability.
Your support empowers me to dedicate more time and resources to improving the project's features, addressing issues, and ensuring its continued relevance in the rapidly evolving landscape of technology.
Your sponsorship directly fuels innovation, fosters a vibrant community, and helps maintain the project's high standards of quality. Together, we can shape the future of the projects and make a lasting impact in the open-source community.
Thank you for considering sponsoring my work!