This project is a RESTful API for a social media platform built using Node.js and MySQL. It supports user authentication with JWT and provides core social media functionalities like user management, posting, and interactions (followers). The project follows a structured MVC architecture, with routes, controllers, and configuration files. Additionally, Swagger is used for documenting the API. This repository is designed to offer scalable and maintainable solutions for social media applications.
Below is an overview of the available endpoints and their functionalities.
- To explore the Swagger UI schema and view available endpoints, navigate to http://localhost:3000/api-docs after running the server.
- You can also test these endpoints via this Postman collection
This project implements the following key features to ensure a robust, secure, and scalable web application:
CRUD Operation
: Full implementation of Create, Read, Update, and Delete functionalities for users, posts, stories and interactions.JWT-Based Authentication:
Secure user authentication using JSON Web Tokens (JWT) to manage user sessions.Password Hashing
: Secure password storage with hashing using thebcryptjs
package.Server-Side Validation
: Input validation using theexpress-validator
package to ensure data integrity and security.Pagination
: Implemented pagination for efficient result retrieval in larger datasets.API Documentation
: IntegratedSwagger
for easy and structured API documentation, improving developer experience and collaboration.
- Clone the repository
git clone https://github.com/carpodok/node-mysql-social-app.git
- Navigate to the project directory:
cd node-mysql-social-app
- Install required dependencies
npm install
- Creat a
.env
file on the root of the project and add the following environment variables.
PORT=3000
JWT_SECRET ="your-jwt-secret"
DB_HOST = "localhost"
DB_USER = "root"
DB_PASSWORD = "your-mysql-password"
DB_NAME="your-db-name"
- To start the server, run the following command on the root of the project path;
npm start
For the development purpose;
npm run dev
- The application will be running on
http://localhost:3000
Contributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.
This project is licensed under the MIT License.