Giter Club home page Giter Club logo

e-commerce-api's Introduction

E-Commerce API

This repository contains the backend code for an e-commerce website's API built with Node.js, Express.js, and MongoDB. The API provides endpoints for users to perform CRUD (Create, Read, Update, Delete) operations on products and orders.

Getting Started

To get started with the project, follow the instructions below:

  1. Clone the repository:
git clone https://github.com/gupta123shivam/E-Commerce-API.git
  1. Install the dependencies:
npm install
  1. Create a .env file in the root directory of the project and add the required environment variables:
PORT=<port number>
MONGO_URI=<MongoDB connection string>
JWT_SECRET=<secret key for JWT>
  1. Start the development server:
npm run dev
  1. Use an API testing tool such as Postman or Insomnia to test the endpoints.

Endpoints

The following endpoints are available in the API:

  • /api/products:
  • GET: get all products
  • POST: create a new product
  • /api/products/:id:
  • GET: get a single product by ID
  • PUT: update a product by ID
  • DELETE: delete a product by ID
  • /api/orders:
  • GET: get all orders
  • POST: create a new order
  • /api/orders/:id:
  • GET: get a single order by ID
  • PUT: update an order by ID
  • DELETE: delete an order by ID

Authentication

The API uses JSON Web Tokens (JWT) for authentication. To access the protected endpoints, you must include a valid JWT in the Authorization header of your request. To obtain a JWT, send a POST request to the /api/users/login endpoint with a valid username and password. The response will include a JWT that you can use to access the protected endpoints.

Error Handling

The API uses custom error handlers to provide informative error messages in case of errors. If an error occurs, the API will return a JSON response with a descriptive error message.

Contributing

Contributions to the project are welcome. To contribute, fork the repository and create a pull request with your changes. Before submitting a pull request, make sure that your changes pass the linting and testing checks.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

e-commerce-api's People

Contributors

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