Giter Site home page Giter Site logo

abhijitsarker / res2ran-server Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 29 KB

The Res2Ran manages user data, menu items, reviews, carts, payments, and provides statistics for an application related to a food delivery service.

Home Page: https://bistro-boss-server-ten-gamma.vercel.app

JavaScript 100.00%
express jason-web-tokens mongodb nodejs

res2ran-server's Introduction

Res2Ran Server

This project is a comprehensive restaurant management platform built on Node.js and Express. It integrates MongoDB for data storage, Stripe for payment processing, and JWT for user authentication. The system facilitates user and admin functionalities such as user management, menu control, reviews, carts, payments, and admin analytics.

Installation Process:

To install and run the project locally, follow these steps:

  1. Clone the repository.
  2. Run npm install to install dependencies.
  3. Set up environment variables in a .env file with necessary configurations (e.g., PORT, DB_USER, DB_PASSWORD, PAYMENT_SECRET_KEY, ACCESS_TOKEN).
  4. Ensure MongoDB is running and accessible.
  5. Run npm start to start the server.
  6. Access the endpoints using a tool like Postman or integrate them into your front-end application.

API Documentation:

Authentication

Generate JWT Token

  • POST /jwt
    • Description: Generates a JSON Web Token (JWT) for user authentication.

    • Request Body: Expects user details to create a token.

      { "email": "[email protected]", "password": "securepassword" }

    • Response: Returns a JWT token for authorized access.

User Management

Retrieve All Users

  • GET /users
    • Description: Retrieves all users registered in the system. (Admin access required)

Register New User

  • POST /users
    • Description: Registers a new user in the system.

    • Request Body: Requires user details for registration.

      { "email": "[email protected]", "password": "newuserpassword", "name": "New User", "role": "customer" }

    • Response: Returns the registration status.

Check Admin Status

  • GET /users/admin/:email
    • Description: Checks if the specified user has admin privileges.
    • Request: Requires the email of the user to be checked.
    • Response: Returns whether the user has admin access.

Upgrade User to Admin

  • PATCH /users/admin/:id
    • Description: Upgrades a user to admin status.
    • Request: Requires the user ID to perform the upgrade.
    • Response: Returns the status of the admin upgrade.

Menu Management

Get Entire Menu

  • GET /menu
    • Description: Retrieves the complete menu of available items.

Add Item to Menu

  • POST /menu
    • Description: Adds a new item to the menu. (Admin access required)

    • Request Body: Expects details of the new menu item.

      { "name": "New Item", "category": "Main Course", "price": 15.99, "description": "Description of the new menu item" }

    • Response: Returns the status of the item addition.

Remove Item from Menu

  • DELETE /menu/:id
    • Description: Removes a menu item by its ID. (Admin access required)
    • Request: Requires the ID of the item to be deleted.
    • Response: Returns the status of the item deletion.

Reviews

Get All Reviews

  • GET /reviews
    • Description: Retrieves all reviews available in the system.

Cart Operations

Get User's Cart

  • GET /carts
    • Description: Retrieves items in the user's cart. (Authenticated user access required)

Add Item to Cart

  • POST /carts
    • Description: Adds an item to the user's cart.

    • Request Body: Requires the details of the item to be added.

      { "itemId": "itemID", "quantity": 2 }

    • Response: Returns the status of the item addition to the cart.

Remove Item from Cart

  • DELETE /carts/:id
    • Description: Removes an item from the user's cart by its ID.
    • Request: Requires the ID of the item to be removed.
    • Response: Returns the status of the item removal from the cart.

Payments

Create Payment Intent

  • POST /create-payment-intent
    • Description: Creates a payment intent for a transaction.

    • Request Body: Requires details for the payment intent.

      { "price": 50.99 }

    • Response: Returns the client secret for payment processing.

Record Payment and Clear Cart

  • POST /payments
    • Description: Records payment details and clears cart items.

    • Request Body: Expects payment and cart information.

      { "paymentId": "paymentID", "cartItems": ["itemID1", "itemID2"], "price": 50.99 }

    • Response: Returns the status of payment recording and cart clearance.

Admin Analytics

Get Admin Statistics

  • GET /admin-stats
    • Description: Retrieves statistics on users, products, orders, and revenue. (Admin access required)

Aggregate Order Statistics

  • GET /order-stats
    • Description: Aggregates data on orders categorized by menu item types. (Admin access required)

Ensure proper authentication headers are included for protected routes and appropriate role permissions are granted for accessing admin functionalities. The server runs on the specified port and connects to MongoDB for data management.

res2ran-server's People

Contributors

abhijitsarker avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.