Skip to content

Latest commit

 

History

History
486 lines (315 loc) · 9.17 KB

README.md

File metadata and controls

486 lines (315 loc) · 9.17 KB

Ordin Backend

Technologies Used

The server is built using the following technologies:
  • Node.js ::: The runtime environment for running JavaScript on the server.

  • Express ::: A web application framework for routing and handling HTTP requests.

  • PostgreSQL ::: A robust, open-source relational database.

  • Prisma ::: An Object-Relational Mapping (ORM) tool for interfacing with the database.

  • JWT (JSON Web Tokens) ::: For user authentication and authorization.

  • Cookie Parser ::: To handle cookies for user sessions.

  • Husky ::: A pre-commit and pre-push hook framework for ensuring code quality.

  • SSL-Commerce ::: For payment gateway integration.

  • Node Mailer ::: For sending email with password reset and actions

API Endpoints and Descriptions

The backend server is built with a focus on modularity, security, and performance. It provides comprehensive functionalities to serve the front-end of the web application, ensuring a seamless and secure user experience. The server's use of Node.js and Express, in combination with other technologies, ensures reliable performance and scalability for a wide range of applications.

modules

Auth Module

  1. Create a New User Account
    • Endpoint:
  POST '/sign-up'
  • Description: Allows users to create a new account with validated user data.
  1. Authenticate a User

    • Endpoint:
    POST '/login`
  • Description: Handles user authentication and generates a JSON Web Token (JWT) for further API access.
  1. Change Password

    • Endpoint:
PATCH '/change-password'
  • Description: Enables users to change their passwords securely and is protected.
  1. Retrieve User Profile

    • Endpoint:
GET '/profile'
  • Description: Retrieves the user's profile (protected).
  1. Get All Users

    • Endpoint:
GET '/allUsers'
  • Description: Lists all users and is protected for admin users to prevent unauthorized access to user data.
  1. Update User Profile

    • Endpoint:
PATCH '/update-profile'
  • Description: Allows users to securely update their profiles. It is protected and includes request validation.
  1. Create Admin User

    • Endpoint:
POST ' /create-admin'
  • Description: Creates admin users is protected for super-admin users.
  1. Delete User

    • Endpoint:
DELETE '/:id'
  • Description: Permits the deletion of user accounts and is protected by admin and super-admin roles to maintain data integrity.
  1. Get Single User Data
    • Endpoint:
GET '/:id'
  • Description: Allows super-admin and admin roles to retrieve the data of a single user securely.

Blogs Module

  1. Create a New Blog
  • Endpoint:
POST '/create'
  • Description: Allows admin and super-admin users to create new blog posts.
  1. Get All Blogs
  • Endpoint:
GET '/all-blogs'
  • Description: Retrieves a list of all blog posts.
  1. Delete a Blog
  • Endpoint:
DELETE '/:id'
  • Description: Permits the deletion of a specific blog post. This endpoint is protected by admin and super-admin roles.

Categories Module

  1. Create a New Category
  • Endpoint:
POST '/categories'
  • Description: Allows authorized users to create new categories for blog posts.
  1. Get All Categories
  • Endpoint:
GET '/categories'
  • Description: Retrieves a list of all available categories.
  1. Get Single Category Data
  • Endpoint:
GET  '/categories/:id'
  • Description: Allows users to retrieve data of a specific category.
  1. Update Category
  • Endpoint:
PATCH /categories/:id
  • Description: Permits users to update the details of a specific category.
  1. Delete Category
  • Endpoint:
DELETE '/categories/:id'
  • Description: Allows users to delete a specific category.

Services Module

  1. Create a New Service
  • Endpoint:
POST '/services'
  • Description: Allows authorized users to create new services.
  1. Get All Services
  • Endpoint:
GET '/services'
  • Description: Retrieves a list of all available services.
  1. Get Single Service Data
  • Endpoint:
GET '/services/:id'
  • Description: Allows users to retrieve data of a specific service.
  1. Update Service
  • Endpoint:
PATCH '/services/:id'
  • Description: Permits users to update the details of a specific service.
  1. Delete Service
  • Endpoint: DELETE /services/:id
  • Description: Allows users to delete a specific service.

Cart Module

  1. Create a New Cart Item
  • Endpoint:
POST '/cart'
  • Description: Allows users to add items to their shopping cart and is protected for user, admin, and super-admin roles.
  1. Get All Cart Items
  • Endpoint:
GET' /cart'
  • Description: Lists all items in the user's shopping cart and is protected for user, admin, and super-admin roles.
  1. Get Single Cart Item
  • Endpoint:
GET /cart/:id
  • Description: Allows users to retrieve data of a single cart item.
  1. Update Cart Item
  • Endpoint:
PATCH '/cart/:id'
  • Description: Permits users to update the details of a specific cart item and is protected for user, admin, and super-admin roles.
  1. Delete Cart Item
  • Endpoint:
DELETE '/cart/:id'
  • Description: Allows users to delete a specific cart item and is protected for user, admin, and super-admin roles.

Booking Module

  1. Get All Bookings
  • Endpoint:
GET '/bookings'
  • Description: Retrieves a list of all bookings, protected for admin and super-admin roles.
  1. Get User's Booking
  • Endpoint:
GET '/bookings/userBooking'
  • Description: Lists all bookings for a user.
  1. Get Booking by Service
  • Endpoint:
GET '/bookings/:serviceId'
  • Description: Retrieves user bookings for a specific service.
  1. Get Single Booking Data
  • Endpoint:
GET '/bookings/:id'
  • Description: Allows users to retrieve data of a single booking.
  1. Delete Booking
  • Endpoint:
DELETE '/bookings/:id'
  • Description: Permits users to delete a specific booking and is protected for admin, super-admin, and user roles.
  1. Update Booking
  • Endpoint:
PATCH '/bookings/:id'
  • Description: Allows users to update the details of a specific booking and is protected for super-admin and admin roles.

Reviews Module

  1. Create a New Review
  • Endpoint:
POST' /reviews'
  • Description: Enables users to create new reviews and is protected for user, admin, and super-admin roles.
  1. Get All Reviews
  • Endpoint:
GET '/reviews'
  • Description: Retrieves a list of all reviews.
  1. Get User's Reviews
  • Endpoint:
GET '/reviews/userReview'
  • Description: Lists all reviews for a user.
  1. Get Reviews by Service
  • Endpoint:
GET '/reviews/userReview/:serviceId'
  • Description: Retrieves user reviews for a specific service.
  1. Get Single Review Data
  • Endpoint:
GET '/reviews/:id'
  • Description: Allows users to retrieve data of a single review.
  1. Update Review
  • Endpoint:
PATCH '/reviews/:id'
  • Description: Permits users to update the details of a specific review and is protected for admin, user, and super-admin roles.
  1. Delete Review
  • Endpoint:
DELETE '/reviews/:id'
  • Description: Allows users to delete a specific review and is protected for admin, user, and super-admin roles.

FAQ Module

  1. Create a New FAQ
  • Endpoint:
POST '/faq'
  • Description: Allows authorized users to create new FAQs.
  1. Get All FAQs
  • Endpoint:
GET '/faq'
  • Description: Retrieves a list of all frequently asked questions.
  1. Get Single FAQ Data
  • Endpoint:
GET '/faq/:id'
  • Description: Allows users to retrieve data of a specific FAQ.
  1. Update FAQ
  • Endpoint:
GET '/faq/:id'
  • Description: Permits users to update the details of a specific FAQ.
  1. Delete FAQ
  • Endpoint:
DELETE '/faq:id'
  • Description: Allows users to delete a specific FAQ.

Payment Module

  1. Initialize Payment
  • Endpoint:
POST '/payment'
  • Description: Initiates the payment process for services.
  1. Handle Webhook
  • Endpoint:
POST '/payment/webhook'
  • Description: Handles incoming webhooks from the payment gateway.
  1. Get All Payments
  • Endpoint:
GET '/payment'
  • Description: Retrieves a list of all payments, protected for admin and super-admin roles.
  1. Get User's Payments
  • Endpoint:
POST '/payment/userPayment'

*** -------------------------------------------Updating payment ------------------------------------***