Skip to content

Commit

Permalink
Ft seller update items 187584929 (#51)
Browse files Browse the repository at this point in the history
* [Delivers #187584924] Seller Create/Add a product

* [Delivers #187584929] Seller Update/Modify a product

* [Delivers #187584929] Seller update product

---------

Co-authored-by: AimePazzo <[email protected]>
  • Loading branch information
Fabrice-Dush and AimePazzo authored Jun 10, 2024
1 parent 73bae0f commit 99c7974
Show file tree
Hide file tree
Showing 24 changed files with 1,773 additions and 1,141 deletions.
68 changes: 33 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo

[https://e-commerce-ninjas-platform-backend.onrender.com/](https://e-commerce-ninjas-platform-backend.onrender.com/)

#### Hosted Swagger Documentation
#### HOSTED SWAGGER DOCUMENTATION

[https://e-commerce-ninjas-platform-backend.onrender.com/api-docs](https://e-commerce-ninjas-platform-backend.onrender.com/api-docs)

#### Github Repository For E-Commerce-Ninjas Backend
#### GITHUB REPOSITORY FOR E-COMMERCE-NINJAS BACKEND

[https://github.com/atlp-rwanda/e-commerce-ninjas-bn](https://github.com/atlp-rwanda/e-commerce-ninjas-bn)

Expand All @@ -29,53 +29,51 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo
- Resend verification Endpoint
- Login Endpoint
- login vie google Endpoint
- Forget Password Endpoint
- Reset Password Endpoint
- Change Password Endpoint
- Admin Update Status Endpoint
- Admin Update Role Endpoint
- Admin get users Endpoint
- Admin get user Endpoint
- Logout Endpoint
- Get User Profile Endpoint
- Get User Profile Endpoint
- User Update Profile Endpoint
- Seller create shop Endpoint
- Seller create product Endpoint
- Seller update product Endpoint
- Seller Delete Item Endpoint
- Seller get statistics Endpoint
- Forget Password Endpoint
- Reset Password Endpoint
- Change Password Endpoint
- Seller update product status Endpoint
- Seller get products Endpoint


## TABLE OF API ENDPOINTS SPECIFICATION AND DESCRIPTION


| No | VERBS | ENDPOINTS | STATUS | ACCESS | DESCRIPTION |
|----|-------|-----------------------------------------|-------------|---------|-------------------------------------|
| 1 | GET | / | 200 OK | public | Show welcome message |
| 2 | POST | /api/auth/register | 201 CREATED | public | create user account |
| 3 | GET | /api/auth/verify-email/:token | 200 OK | public | Verifying email |
| 4 | POST | /api/auth/send-verify-email | 200 OK | public | Resend verification email |
| 5 | POST | /api/auth/login | 200 OK | public | Login with Email and Password |
| 6 | POST | /api/auth/google | 200 OK | public | Login Via google account |
| 7 | POST | /api/auth/logout | 200 OK | private | Logout user |
| 8 | POST | /api/auth/forget-password | 200 OK | public | Forget Password |
| 9 | POST | /api/auth/reset-password/:token | 200 OK | public | Reset Password |
| 10 | PUT | /api/user/user-update-profile | 200 OK | private | Update User Profile Endpoint |
| 11 | GET | /api/user/user-get-profile | 200 OK | private | Get User Profile Endpoint |
| 12 | GET | /api/user/change-password | 200 OK | private | User Update password |
| 13 | PUT | /api/user/admin-update-user-status/:id | 200 OK | private | Admin Update Status Endpoint |
| 14 | PUT | /api/user/admin-update-role/:id | 200 OK | private | Admin Update role Endpoint |
| 15 | GET | /api/user/admin-get-users | 200 OK | private | Admin get all users Endpoint |
| 16 | GET | /api/user/admin-get-user/:id | 200 OK | private | Admin get one user Endpoint |
| 17 | POST | /api/shop/seller-create-shop | 201 OK | private | Create shop for products |
| 18 | POST | /api/shop/seller-create-product | 201 OK | private | create product in shop |
| 19 | DELETE| /api/shop/delete-product/:id | 200 OK | private | Delete Item in Collection |
| 20 | POST | /api/shop/seller-statistics | 200 OK | public | Get seller statistics per timeframe |
| 21 | PUT | /api/shop/seller-update-product-status/:id | 200 OK | private | Seller update product status |
| 22 | GET | /api/shop/seller-get-products | 200 OK | private | Seller get products |


| No | VERBS | ENDPOINTS | STATUS | ACCESS | DESCRIPTION |
| --- | ------ | ------------------------------------------ | ----------- | ------- | ----------------------------------- |
| 1 | GET | / | 200 OK | public | Show welcome message |
| 2 | POST | /api/auth/register | 201 CREATED | public | create user account |
| 3 | GET | /api/auth/verify-email/:token | 200 OK | public | Verifying email |
| 4 | POST | /api/auth/send-verify-email | 200 OK | public | Resend verification email |
| 5 | POST | /api/auth/login | 200 OK | public | Login with Email and Password |
| 6 | POST | /api/auth/google | 200 OK | public | Login Via google account |
| 7 | POST | /api/auth/logout | 200 OK | private | Logout user |
| 8 | POST | /api/auth/forget-password | 200 OK | public | Forget Password |
| 9 | POST | /api/auth/reset-password/:token | 200 OK | public | Reset Password |
| 10 | PUT | /api/user/user-update-profile | 200 OK | private | Update User Profile Endpoint |
| 11 | GET | /api/user/user-get-profile | 200 OK | private | Get User Profile Endpoint |
| 12 | GET | /api/user/change-password | 200 OK | private | User Update password |
| 13 | PUT | /api/user/admin-update-user-status/:id | 200 OK | private | Admin Update Status Endpoint |
| 14 | PUT | /api/user/admin-update-role/:id | 200 OK | private | Admin Update role Endpoint |
| 15 | GET | /api/user/admin-get-users | 200 OK | private | Admin get all users Endpoint |
| 16 | GET | /api/user/admin-get-user/:id | 200 OK | private | Admin get one user Endpoint |
| 17 | POST | /api/shop/seller-create-shop | 201 OK | private | Create shop for products |
| 18 | POST | /api/shop/seller-create-product | 201 OK | private | create product in shop |
| 19 | PUT | /api/shop/seller-update-product/:id | 200 OK | private | update product in shop |
| 20 | DELETE | /api/shop/delete-product/:id | 200 OK | private | Delete Item in Collection |
| 21 | POST | /api/shop/seller-statistics | 200 OK | private | Get seller statistics per timeframe |
| 22 | PUT | /api/shop/seller-update-product-status/:id | 200 OK | private | Seller update product status |
| 23 | GET | /api/shop/seller-get-products | 200 OK | private | Seller get products |

## INSTALLATION

Expand Down Expand Up @@ -152,4 +150,4 @@ Our e-commerce web application server, developed by Team Ninjas, facilitates smo
9. Delete the Migration:
```sh
npm run deleteAllTables
```
```
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"createAllSeeders": "tsc && npx sequelize db:seed:all",
"deleteAllTables": "tsc && npx sequelize db:migrate:undo:all",
"deleteAllSeeders": "tsc && npx sequelize db:seed:undo:all",
"start": "src/index.ts",
"start": "nodemon src/index.ts",
"dev": "nodemon src/index.ts",
"test": "cross-env NODE_ENV=test npm run deleteAllTables && cross-env NODE_ENV=test npm run createAllTables && cross-env NODE_ENV=test npm run createAllSeeders && nyc cross-env NODE_ENV=test mocha --require ts-node/register 'src/**/*.spec.ts' --timeout 600000 --exit",
"test-local": "cross-env NODE_ENV=development npm run deleteAllTables && cross-env NODE_ENV=development npm run createAllTables && cross-env NODE_ENV=development npm run createAllSeeders && nyc cross-env NODE_ENV=development mocha --require ts-node/register 'src/**/*.spec.ts' --timeout 600000 --exit",
Expand Down
39 changes: 20 additions & 19 deletions src/databases/migrations/20240601223524-create-products.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable comma-dangle */
/* eslint-disable @typescript-eslint/no-explicit-any */
import { QueryInterface, DataTypes } from "sequelize";

Expand All @@ -8,74 +9,74 @@ export default {
allowNull: false,
primaryKey: true,
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4
defaultValue: DataTypes.UUIDV4,
},
shopId: {
allowNull: false,
type: DataTypes.UUID,
references: {
model: "shops",
key: "id"
key: "id",
},
onDelete: "CASCADE"
onDelete: "CASCADE",
},
name: {
allowNull: false,
type: DataTypes.STRING
type: DataTypes.STRING,
},
description: {
type: DataTypes.STRING,
allowNull: true
allowNull: true,
},
price: {
allowNull: false,
type: DataTypes.DECIMAL(10, 2)
type: DataTypes.DECIMAL(10, 2),
},
discount: {
type: DataTypes.STRING,
allowNull: true
allowNull: true,
},
category: {
allowNull: false,
type: DataTypes.STRING
type: DataTypes.STRING,
},
expiryDate: {
type: DataTypes.DATE
type: DataTypes.DATE,
},
expired: {
type: DataTypes.BOOLEAN,
defaultValue: false
defaultValue: false,
},
bonus: {
type: DataTypes.STRING
type: DataTypes.STRING,
},
images: {
type: DataTypes.ARRAY(DataTypes.STRING)
type: DataTypes.ARRAY(DataTypes.STRING),
},
quantity: {
allowNull: false,
type: DataTypes.INTEGER,
defaultValue: 0
defaultValue: 0,
},
status: {
type: DataTypes.STRING(128),
allowNull: false,
defaultValue: "available"
defaultValue: "available",
},
createdAt: {
allowNull: false,
type: DataTypes.DATE,
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP")
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
},
updatedAt: {
allowNull: false,
type: DataTypes.DATE,
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP")
}
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"),
},
});
},

down: async (queryInterface: QueryInterface) => {
await queryInterface.dropTable("products");
}
};
},
};
29 changes: 15 additions & 14 deletions src/databases/migrations/20240607150545-create-cart-products.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable comma-dangle */
import { QueryInterface, DataTypes } from "sequelize";

export = {
Expand All @@ -7,58 +8,58 @@ export = {
type: DataTypes.UUID,
allowNull: false,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
primaryKey: true,
},
productId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: "products",
key: "id"
key: "id",
},
onUpdate: "CASCADE",
onDelete: "CASCADE"
onDelete: "CASCADE",
},
cartId: {
type: DataTypes.UUID,
allowNull: false,
references: {
model: "carts",
key: "id"
key: "id",
},
onUpdate: "CASCADE",
onDelete: "CASCADE"
onDelete: "CASCADE",
},
quantity: {
type: DataTypes.INTEGER,
allowNull: true
allowNull: true,
},
discount: {
type: DataTypes.FLOAT,
allowNull: true
allowNull: true,
},
price: {
type: DataTypes.FLOAT,
allowNull: false
allowNull: false,
},
totalPrice: {
type: DataTypes.FLOAT,
allowNull: false
allowNull: false,
},
createdAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
defaultValue: DataTypes.NOW,
},
updatedAt: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
}
defaultValue: DataTypes.NOW,
},
});
},

down: async (queryInterface: QueryInterface) => {
await queryInterface.dropTable("cart_products");
}
};
},
};
Loading

0 comments on commit 99c7974

Please sign in to comment.