Discription:
something something really important.
Phase 1 :
An E-commerce app will have the following features
1. An user that can create a account(signUp) and logIn/signIn with the account credentials.
2. An user will have a profile that he can add/update/delet personal information. an user will have only one profile.
3. There will be category and sub-category of products.
4. Product create/update/upload/delete/stockupdate can be done by admin.
5. filter of product based on category/name/etc
-query string
6.shopping cart/ orders/checkouts/wishlists.
Node.js (environment:local,version:16.9.1 )
npm (environment:local,version:7.21.1)
express.js
mongodb with mongoose
- Primary packages
dotenv, express, morgan, bcrypt,jasonwebtoken, joi, lodash, cors and mongoose
- express-async-errors
-
creation of usermodel userController and userRoutes for registration of user and logIn of user(all user will have a default role "user")
-
for a better way to handle promise related error, a package 'express-async-error is used' and a global middleware is defined to check Promise related errors.
-
written authorization middleware for token validation and role based authorization via midlleware.
tasks:
1. category, product and subcategory model creation.
2. category ans products routes
3. file upload for product.(image/videos)
4. product filter (query string/or any other sort !)
==> images uploaded from frontend with from data so to handle from data in tha back end we need to use a package "formidable".
==> learning Form object of javaScript, formidable(npm package)
when data is send as form data as http/xrs request contents of that data does not store in req.body as they are not send as json object, so we will fromidable to parse tha data and then use node modules built-in file system to read the incoming data and save them on the db. the data is saved as binary thou.
using the nodes built-in file-system to read data and store it in product object and save in data base but data is saved as a buffer binary
query string can pass data ad key valu pair. The data is recived as req.query as an object of key valie pair.
req.query:{
order: "desec",
limit: "10",
sortBy: "name"
}
all data that is recived is always string type or integers must be parsed.
query params are append after the question mark this: .../api/product?order=desec&limit=10&sortBy=name/ Now for Updating product by ID steps: get product by id collect data Update Provided from fields Update photo (if provided)
- gotta be flexiable
- filtering the product with a dedicated route with more functionallity.
- features to be included
1.order ascending-desending,
2. show product by sold,
3. load more Button,
4. Product Review,
5. Coupon Option,
6. Show Parchase history,
7. Validate Payment,