Welcome to the Sarahah API project! This project serves as the backend for a messaging application, inspired by the popular "Sarahah" concept, where users can send anonymous messages to others. The API is built using Node.js and Express, with MongoDB as the database. It also integrates Joi and Bcryptjs for validation and security, and Cloudinary for seamless media upload capabilities.
- Introduction.
- Features.
- Technologies Used & Dependencies.
- Project Structure.
- Getting Started.
- API Endpoints.
- Available Base Url.
- Authentication and Security.
- Validation.
- Media Upload.
- Feedback and Contributing.
- License.
The Sarahah API project provides a robust backend foundation for creating an anonymous messaging application.
- User registration and authentication.
- Send and receive anonymous messages.
- Input validation using Joi.
- Password hashing with Bcryptjs.
- Seamless media uploads using Cloudinary.
- Node.js: A server-side JavaScript runtime used to build fast and scalable network applications.
- Express: A minimal and flexible Node.js web application framework that simplifies API development.
- MongoDB: A NoSQL database used for efficient and flexible data storage.
- Joi: A validation library for JavaScript that helps ensure the integrity of data.
- Bcrypt.js: A library for hashing and salting passwords to enhance security.
- Cloudinary: A cloud-based media management platform for uploading, storing, and delivering images and other media.
For a complete list of dependencies, please refer to the package.json
file.
To get started with the Fresh Cart frontend project, follow these steps:
- Clone the Repository: Clone this repository to your local machine using the following command:
git clone https://github.com/Dragon-H22/Sarahah-App-API.git
- Install Dependencies: Navigate to the project directory and install the required dependencies using your preferred package manager:
cd Sarahah-App-API
npm install
-
Configure environment variables: Add variables for database connection, Cloudinary API keys, JWT secret, and token signature.
-
Run the Application: Start the development server to run the application locally:
npm run dev
- Access the Application: Open your web browser and visit
http://localhost:5000
to use it as a base link.
The project structure follows a modular pattern to enhance maintainability and readability:
DB/
Models/
: Defines MongoDB schemas.connection.js
: Connect to MongoDB.
src/
middleware/
: Middleware functions for authentication, error handling, etc.modules/
: Defines API routes and connects them to controllers to perform their business logic.utils/
: Utility functions for various tasks.app.js
: Main Express application setup.
- Authentication
POST /auth/login
: Login user.POST /auth/signup
: Register new user.
- User
GET /user/profile
: Retrieve details of a profile user.GET /user/:id/profile
: Retrieve details of a specific profile user to share it.PATCH /user/password
: Update the password of the user.PATCH /user/profilePic
: Upload the profile image of the user.PATCH /user/profileCovPic
: Upload cover images for the user profile with a maximum of 5 images.
- Message
GET /message
: Retrieve all messages.POST /message/:receiverId
: Send a message to a specific user by his id.DELETE /message/:messageId
: Delete message.
Detailed Postman API documentation can be found here.
- https://saraha-app-api.vercel.app/
- https://saraha-app-api-dragon-h22.vercel.app/
- https://saraha-app-api-git-master-dragon-h22.vercel.app/
User passwords are securely hashed using Bcryptjs before being stored in the database. This ensures the confidentiality of user credentials.
Joi is used to validate incoming data for user registration, login, and message sending. This ensures that only valid data is processed by the API.
The integration with Cloudinary allows users to upload media files, such as images, for their profile.
I'm excited to hear your feedback and discuss potential collaborations and if you'd like to contribute, please fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT license.