Skip to content

Hossam-H22/Sarahah-App-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sarahah API

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.


Table of Contents


Introduction

The Sarahah API project provides a robust backend foundation for creating an anonymous messaging application.


Features

  • User registration and authentication.
  • Send and receive anonymous messages.
  • Input validation using Joi.
  • Password hashing with Bcryptjs.
  • Seamless media uploads using Cloudinary.

Technologies Used & Dependencies

  • 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.


Getting Started

To get started with the Fresh Cart frontend project, follow these steps:

  1. 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
  1. Install Dependencies: Navigate to the project directory and install the required dependencies using your preferred package manager:
  cd Sarahah-App-API
  npm install
  1. Configure environment variables: Add variables for database connection, Cloudinary API keys, JWT secret, and token signature.

  2. Run the Application: Start the development server to run the application locally:

  npm run dev
  1. Access the Application: Open your web browser and visit http://localhost:5000 to use it as a base link.

Project Structure

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.

API Endpoints

  • 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.


Available Base Url


Authentication and Security

User passwords are securely hashed using Bcryptjs before being stored in the database. This ensures the confidentiality of user credentials.


Validation

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.


Media Upload

The integration with Cloudinary allows users to upload media files, such as images, for their profile.


Feedback and Contributing

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.


License

This project is licensed under the MIT license.



About

Api for a messaging app where users can send anonymous messages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published