Skip to content

shivamvijaywargi/AmmaJaan-backend

Repository files navigation

AmmaJaan

This is an eCommerce Backend written in NodeJS(ExpressJS) with TypeScript

Tech Badges

Some of the things that I have used

NodeJS Express.js TypeScript MongoDB JWT Next Cloud Gmail

Tech Stack

Frontend: Not sure yet😢

Backend: NodeJS, ExpressJS, TypeScript, MongoDB, Mongoose, JWT

PS: For complete list of packages check out package.json😉

Features

  • AUTH - Register, Login, Logout, Forgot Password, Reset Password
  • USER - Get user, update user, delete user, upload avatars
  • PRODUCT - Create, get all, get single, update, delete product(s)
  • Uses Refresh Token + Access Token mechanism for relatively better security

API Reference - Only single example since I cannot write all here😅

Get all products

  GET /api/v1/products

Get single product

  GET /api/products/${id}
Parameter Type Description
id string(ObjectId) Required. Id of product to fetch

Demo

I might make a Swagger documentation in the future, if I can learn it sooner.

Roadmap

  • Coupon

  • Addresses

  • Order

  • Payment integration

  • Review

  • Wishlist

  • Learn Swagger, Testing and implement them

Installation

Install AmmaJaan with yarn (You can choose others as well but I used yarn)

  # First of all clone the repo
  git clone https://github.com/shivamvijaywargi/full-stack-eCommerce.git
  # Now cd into the cloned repo
  cd full-stack-eCommerce
  # First we need to install dependencies
  yarn
  # Finally use this command to run the server in dev mode (For other commands check package.json)
  yarn start:dev

Environment Variables

To run this project, you will need to add the following environment variables to your .env file, please checkout the .env.example for a list of variables you will need😊

Contributing

Contributions are always welcome!

See contributing.md(In process) for ways to get started.

Please adhere to this project's code of conduct.

Lessons Learned

Achieving

  • Improved my knowledge on building backend using TS
  • Learned about Zod and how to create Zod schemas for validation
  • How to create interfaces for mongoose schemas
  • First time using formidable and it was a good experience
  • Basic API security using express-rate-limit + helmet
  • Need something out of built-in fs package, fs-extra is what you need😉
  • Create user friendly URLs with Slug (Say NO to 63e722d56f4c46aa8c65a82f)
  • Better logging using Winston + Morgan (A level up compared to console logs)
    • PS: Do not block your only thread (IFKYK)

Yet to achieve

There are still a few things I still need to dive into which includes but not limited to

  • Use Zod in conjunction with Formidable to be able to create schema to check for fields as well.

  • Docker

  • ESLint

  • Prettier

  • Husky

  • Test with Jest

Optimizations

  • Used Zod for Schema validation where it was necessary to reduce something like

    if (!name || !email || ....) {
        return next(new AppErr(...))
    }
    
    if (name.length < 5) {
        return next(new AppErr(...))
    }
  • Refactored routes to use router.route and chain them instead of router.get, router.post, and so on and so forth

    router.route('/').post(createProduct).get(getAllProducts);
    
    router
      .route('/:id')
      .get(getProductById)
      .put(updateProductById)
      .delete(deleteProductById);

Authors

🛠 My Skills

HTML, CSS, Javascript, ReactJS, NextJS, NodeJS, ExpressJS, MongoDB, TypeScript

Feedback

If you have any feedback, please reach out to me at any of the links given below

🔗 Links

LinkedIn Telegram
linkedin Telegram
Twitter Instagram
twitter Instagram

Appendix

First of all, thank you for reading through the README and now a request from my end. If you think there is some issue with the code or a piece of code can be improved, please feel free to open an issue, or if possible please submit a PR. I would be glad to learn things and improve myself.

Releases

No releases published

Packages

No packages published

Languages