/ecom_api

Primary LanguageJavaScript

E-com-API with node and mongo.

Discription:

something something really important.

Tasks

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.

Stacks Used:

Node.js (environment:local,version:16.9.1 )
npm (environment:local,version:7.21.1)
express.js
mongodb with mongoose

Packages installed

- Primary packages
    dotenv, express, morgan, bcrypt,jasonwebtoken, joi, lodash, cors and mongoose
- express-async-errors

Daily work log

Day: 01 21 november 2021:

  1. creation of usermodel userController and userRoutes for registration of user and logIn of user(all user will have a default role "user")

  2. 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.

  3. written authorization middleware for token validation and role based authorization via midlleware.

phase 2

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 !)

Day : 02 22 novenber 2021:

==> 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)

Day : 02 23 novenber 2021:

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

Day : 03 24 nov 2021:

get the damm product at first

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)

Now how about filter function?

- gotta be flexiable
- filtering the product with a dedicated  route with more functionallity.
- features to be included

task list:

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,