GithubHelp home page GithubHelp logo

rberkkaratas / ecommerce-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 144 KB

This is a simple API for an e-commerce application. It uses Express.js for routing and MongoDB for the database.

Home Page: https://ecommerceapi-bhqwl3xdn-iamberk.vercel.app/

JavaScript 100.00%
api ecommerce express mongodb

ecommerce-api's Introduction

E-Commerce API with Express & MongoDB

v1.1.2

Description

This is a simple API for an e-commerce application. It uses Express.js for routing and MongoDB for the database. It has the following features:

  • ✅CRUD operations for products and orders
  • ✅CORS, Rate Limiting, and Sanitize middleware
  • ✅User authentication with JWT
  • Image upload with Multer
  • Pagination
  • Filtering
  • Sorting
  • Searching
  • ✅Error handling
  • Logging
  • Unit and integration testing
  • ✅Deployment to Vercel

Installation

  1. Clone the repository
git clone https://github.com/iamberk/ecommerce-api
  1. Install dependencies
npm install
  1. Create a .env file in the root directory and add the following environment variables
PORT = 5000

MONGO_URI = your-mongodb-uri

JWT_SECRET_KEY = <JWT_SECRET_KEY>
JWT_EXPIRES_IN = "7d"

JWT_TEMPORARY_KEY = <JWT_TEMPORARY_KEY>
JWT_TEMPORARY_EXPIRES_IN = "3m"
  1. Run the app
npm start

Usage

Authentication

In this version, this API uses JWT for authentication. You can register a user with the /api/v1/register endpoint. You can login with the /api/v1/login endpoint. You can get a user by JWT with the /api/v1/me endpoint. You can update a user with the /api/v1/update-user/:id endpoint. You can delete a user with the /api/v1/delete-user/:id endpoint.

Get all Users

GET /api/v1/get-users

Get a User

GET /api/v1/get-user/:id

Get a User by JWT

GET /api/v1/me
  • Headher: Authorization: Bearer ${token}

Register a User

POST /api/v1/register
  • Body: firstname, lastname, pronounce, email, password

Login a User

POST /api/v1/login
  • Body: email, password

Update a User

PATCH /api/v1/update-user/:id
  • Body: password, firstname, lastname

Delete a User

DELETE /api/v1/delete-user/:id

Categories

In this version, category feature is not included. It will be added in the next versions.

Products

In this version, this API provides Product CRUD operations. You can get all products with the /api/v1/get-products endpoint. You can get a product with the /api/v1/get-product/:id endpoint. You can create a product with the /api/v1/create-product endpoint. You can update a product with the /api/v1/update-product/:id endpoint. You can delete a product with the /api/v1/delete-product/:id endpoint.

Get all Products

GET /api/v1/get-products

Get a Product

GET /api/v1/get-product/:id

Create a Product

POST /api/v1/create-product
  • Body: name, description, image, category

Update a Product

PATCH /api/v1/update-product/:id
  • Body: name, description, image, category

Delete a Product

DELETE /api/v1/delete-product/:id

Orders

In this version, order feature is not included. It will be added in the next versions.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

ISC

ecommerce-api's People

Contributors

rberkkaratas avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.