GithubHelp home page GithubHelp logo

shivamvijaywargi / ammajaan-backend Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 1.0 725 KB

eCommerce backend written in NodeJS + TypeScript + MongoDB (Mongoose)

Home Page: https://ammajaan-backend.onrender.com/api/ping

License: GNU General Public License v3.0

Shell 0.08% TypeScript 99.47% Dockerfile 0.18% JavaScript 0.27%
ecommerce express mongodb mongoose nodejs typescript

ammajaan-backend's Introduction

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.

ammajaan-backend's People

Contributors

shivamvijaywargi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

fang-zhang

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.