Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage product #62

Merged
merged 1 commit into from
May 16, 2024
Merged

Manage product #62

merged 1 commit into from
May 16, 2024

Conversation

wayneleon1
Copy link
Contributor

@wayneleon1 wayneleon1 commented May 13, 2024

What does this PR do?

This pull request adds the product management feature to our app. It defines the products and the category models, categories are used to group products which means there is a relationship between product and category model.
The PR also allows vendors to perform all CRUD Operations on Products and Categories such means a vendor can add, update, read, and delete products and categories

Description of Task to be completed?

Create

  • An Endpoint for sellers to create categories and products
  • Validate the requesting user's role as a seller
  • Validate the request body (price, name, category, expiry date, bonus, etc.)
  • Check if the category exists in the database, if not add it to the database to be used by all sellers
  • Check if the target a product exists in the database
  • If the item does not exist, add it to the database
  • Error handling and appropriate response messages for validation failures
  • Input sanitization
  • Ensuring the product has a reference to the associated seller

Read

  • An API endpoint for retrieving all products and one product based on Id
  • An API endpoint for retrieving all categories and one category based on Id

Update

  • Implement an API endpoint for updating a seller's product details
  • Implement an API endpoint for updating category details
  • Validate the requesting user's role as a seller
  • Retrieve the product from the database based on the provided product ID
  • Update the product and category details in the database
  • Implement error handling and appropriate response messages for validation failures
  • Implement input sanitization

Delete

  • Implement an API endpoint for deleting a product or category based on ID
  • Validate the requesting user's role as a seller
  • Retrieve the product or category from the database based on the provided product or category ID
  • Delete the product or category from the database
  • Implement error handling and appropriate response messages for validation failures
  • Implement input sanitization

How to Test

Clone the Branch, install all dependencies and run this command: npm run dev

First Register as a vendor if you do not have an account(if you have account skip to number 3)
POST: http://localhost:3000/api/v1/register

Verify your account by providing your code from your email
POST: http://localhost:3000/api/v1/confirm

Login and get Token from email
POST: http://localhost:3000/api/v1/login

Verify 2FA
POST: http://localhost:3000/api/v1/verify2FA/:userId

Add a category
POST: http://localhost:3000/api/v1/category

Add a product
POST: http://localhost:3000/api/v1/product

Update a category
PUT: http://localhost:3000/api/v1/category/{categoryId}

Update a product
PUT: http://localhost:3000/api/v1/product/:productId

Delete a product
DELETE: http://localhost:3000/api/v1/product/{productId}

Delete a Category
DELETE: http://localhost:3000/api/v1/category/{categoryId}

Get all products and one product by Id
GET: http://localhost:3000/api/v1/product/
GET: http://localhost:3000/api/v1/product/{productId}

Get all categories and one category by Id
GET: http://localhost:3000/api/v1/category
GET: http://localhost:3000/api/v1/category/{categoryId}

Test Screenshots

56c0a0c7-4096-427c-8ef0-4f42e4822c02

Swagger Screenshot

WhatsApp Image 2024-05-16 at 18 10 09

Any background context you want to provide?

Right know there are some features that have been not added yet such as Currency and Seller Collection features, we worked on whats important for the team member who are depending on our PR to start working, but we are looking for a way to implement these feature after merging.

@wayneleon1 wayneleon1 added backend Good for newcomers WIP Work In Progress labels May 13, 2024
@wayneleon1 wayneleon1 added this to the Product Management milestone May 13, 2024
@wayneleon1 wayneleon1 linked an issue May 13, 2024 that may be closed by this pull request
31 tasks
@wayneleon1 wayneleon1 force-pushed the ft-manage-product-#37 branch 7 times, most recently from 2d1eefb to d6e6ead Compare May 16, 2024 15:44
ambroisegithub
ambroisegithub previously approved these changes May 16, 2024
Copy link
Contributor

@ambroisegithub ambroisegithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It Look good for Me!!!

EddyShimwa
EddyShimwa previously approved these changes May 16, 2024
Copy link
Contributor

@EddyShimwa EddyShimwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wayneleon1 wayneleon1 dismissed stale reviews from EddyShimwa and ambroisegithub via c72e3b6 May 16, 2024 17:02
@wayneleon1 wayneleon1 force-pushed the ft-manage-product-#37 branch 3 times, most recently from d6e6ead to addf31c Compare May 16, 2024 17:11
-define roles and permissions for vendors and buyers
-assign roles and permissions to users during registration or profile update
-enforce role-based access control throughout the application
-write comprehensive unit tests

[Delivers #34]

* feat(rbac): integrate rbac into user registration

-integrate role based access control into user registration

[Delivers #34]

* feat(rbac): integrate rbac into user registration

-integrate role based access control into user registration

[Delivers #34]

---------

Co-authored-by: ambroisegithub <[email protected]>

Social Logins (#45)

* squashing commits

implementing routes for auth

create passport callback function

adding new user from Google

creating new user

check if user is exist in db

implementing cookie session

Fix error of TypeError: req.session.regenerate is not a function using Passport

fix secret keys

remove Google client secret keys

working on facebook strategy

get email from fb login and update the scope

after verification save the user into db

add profile image in db

fixing minor bugs

fix minor bugs in codes

after rebasing & updating some fts

link social login with userModel

Addong Google client keys & FB client key into yml

send confrim email after register a new user

send email after register from facebook

fix minor bugs

* fix minor errors

* remove lints errors

user register

register user test

register user testing fix

register user testing fix

register user testing fix

Authentication for User

Added slint changes

removed  mocha

 added new features

 added new features

Solved comflicts

changed file

added changes

added new Test

added new Test

resolved test cases

resolved test cases

implemented two-factor authentication for enhanced security

implemented two-factor authentication for enhanced security

check whether the usertype is vendor to proceed with 2FA

test the 2fa authentication

Design the database schema for storing seller products and related information

create endpoints for category and also database schema

fix routes for products & categories

implement CRUD operations for category entity

create swagger docs for category routes

adds delete  documentation for category routes

complete documentation for category routes

implementing craate new product route and its controller

implementing get product route and its controller

working on update function

Extend API endpoints

store reference ID of vendor

ft-Product-Docs

This PR add the product swagger docs and some test category

bug-documentation-fixes

Fixing the errors on the doumentation

add new tests for buyers login

Design the database schema for storing seller products and related information

create endpoints for category and also database schema

fix routes for products & categories

implement CRUD operations for category entity

create swagger docs for category routes

adds delete  documentation for category routes

complete documentation for category routes

implementing craate new product route and its controller

implementing get product route and its controller

working on update function

Extend API endpoints

store reference ID of vendor

ft-Product-Docs

This PR add the product swagger docs and some test category

bug-documentation-fixes

Fixing the errors on the doumentation

store reference ID of vendor

replacing try & catch with errorHandler middleware

remove all try & catch blocks in product controller

validating routes

fix minor errors in test categories

Category-testing

add category testing cases

init commit for prouct test

product controller test

complete product test

merging all commits

delete product data after testing

add --detectOpenHandles flag
Copy link
Contributor

@ambroisegithub ambroisegithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks Good for me!!!

Copy link
Collaborator

@Habinezajanvier Habinezajanvier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Habinezajanvier Habinezajanvier merged commit 87b2694 into develop May 16, 2024
3 checks passed
@wayneleon1 wayneleon1 removed the WIP Work In Progress label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Manage a Product
6 participants