dishamodi0910 / APIVerse

APIVerse is a collection of APIs that are useful for developers. It simplifies the process of both adding new APIs and learning how to harness the power of existing ones.
MIT License
78 stars 90 forks source link

[New API] : Ecommerce API #116

Open sujal-98 opened 6 months ago

sujal-98 commented 6 months ago

Brief Description 🤓

The eCommerce API provides endpoints for user authentication, product management, shopping cart functionality, and order processing. Secure access is ensured via JSON Web Tokens (JWT).

Endpoint: /api/auth/register Method: POST Description: Registers a new user and returns a JWT token.

Endpoint: /api/auth/login Method: POST Description: Authenticates a user and provides a JWT token. Products

Endpoint: /api/products/add Method: POST Description: Adds a new product. Requires admin authentication.

Endpoint: /api/products/ Method: GET Description: Retrieves a list of all products.

Endpoint: /api/products/find/:id Method: GET Description: Retrieves the product with associated ids.

Endpoint: /api/products/upd/:id Method: PUT Description: Updates an existing product. Requires admin authentication.

Endpoint: /api/products/del/:id Method: DELETE Description: Deletes a product. Requires admin authentication. Cart

Add Product to Cart

Endpoint: /api/cart/add Method: POST Description: Adds a product to the user's cart. Requires authentication.

Endpoint: /api/cart/ Method: GET Description: Retrieves the user's cart contents.

Endpoint: /api/cart/upd/:productId Method: PUT Description: Updates the quantity of a product in the cart. Requires authentication.

Endpoint: /api/cart/del/:productId Method: DELETE Description: Removes a product from the cart. Requires authentication. Orders

Endpoint: /api/orders/add Method: POST Description: Places an order from the cart. Requires authentication.

Endpoint: /api/orders Method: GET Description: Retrieves a list of the user's orders.

Endpoint: /api/orders/upd/:id Method: Put Description: Make changes to an order.

Endpoint: /api/orders/del/:id Method: Delete Description: deletes an order.

Endpoint: /api/orders/income Method: GET Description: Calculates the monthly sales for admin. Requires authentication.

How will you develop it?🤩

Initialize Node.js and Express project. Create directory structure: routes, models, middleware.

Database Integration

Use MongoDB with Mongoose. Define models for Users, Products, Carts, Orders. User Authentication

Implement JWT authentication middleware. Protect admin routes.

Create routes for: Registration (/api/auth/register) Login (/api/auth/login)

Product Management

Create routes for:

Add Product (/api/products/add) View Products (/api/products) View Specific Product (/api/products/find/:id) Update Product (/api/products/upd/:id) Delete Product (/api/products/del/:id)

Shopping Cart

Create routes for: Add to Cart (/api/cart/add) View Cart (/api/cart) Update Cart Item (/api/cart/upd/:productId) Remove from Cart (/api/cart/del/:productId)

Order Processing

Create routes for: Place Order (/api/orders/add) View Orders (/api/orders) Update Order (/api/orders/upd/:id) Delete Order (/api/orders/del/:id) View Monthly Sales (/api/orders/income) Middleware and Security

Deployment

None

Select the open source program you are contributing to

Other

Code of Conduct

dishamodi0910 commented 6 months ago

Greetings @sujal-98🎀 ! , We are excited to have you dive into another issue with us!🚀 Your involvement in our project has been invaluable, and we're confident that your skills and insights will help us conquer this challenge😇.

Use command /gssoc24 to self assign the issue.

This issue represents an exciting opportunity for us to improve and enhance our project, and we are thrilled to have you on board. We request you to follow CONTRIBUTING GUIDELINES. Looking for your PR soon! In case of any issues, you can contact us on Discord.❣️

sujal-98 commented 6 months ago

/gssoc24