Skip to content

cannonmaster/express-mongo-ecommerce-api

Repository files navigation

Express Mongo Ecommerce API

License: MIT

This project is an Express.js-powered RESTful API for an ecommerce application that uses MongoDB as the database. It provides endpoints for managing products, categories, review, users and orders.

Prerequisites

Before running the application, make sure you have the following installed:

  • Node.js (v14 or higher)
  • MongoDB

Getting Started

  1. Clone the repository:
git clone https://github.com/cannonmaster/express-mongo-ecommerce-api.git
  1. Navigate to the project directory:
cd express-mongo-ecommerce-api
  1. Install the dependencies:
npm install
  1. Configure the environment variables:

    • Create a .env file and palce it in the root directory.
    • Add the necessary environment variables (e.g., database connection string, JWT secret, etc.) to the .env file. You can refer to the example.env file for the required variables.
  2. Start the application:

npm start

The API server will start running on http://localhost:3000.

API Endpoints

Products

  • GET /api/v1/products - Get all products
  • GET /api/products/:id - Get a single product by ID
  • POST /api/v1/products - Create a new product
  • PATCH /api/v1/products/:id - Update a product by ID
  • DELETE /api/v1/products/:id - Delete a product by ID

Users

  • GET /api/v1/users - Get all users
  • GET /api/v1/users/:id - Get a single user by ID
  • GET /api/v1/users/showMe - Get current user
  • PATCH /api/v1/users/updateUser - Update a user by ID
  • PATCH /api/v1/users/updateUserPassword - Update a user password

reviews

  • GET /api/v1/reviews - Get all reviews
  • GET /api/v1/reviews/:id - Get a single review
  • POST /api/v1/reviews - Create a new review
  • PATCH /api/v1/reviews/:id - Update an review
  • DELETE /api/v1/reviews/:id - delete all reviews

Orders

  • GET /api/orders - Get all orders
  • GET /api/orders/:id - Get a single order by ID
  • POST /api/v1/orders - Create a new order
  • PUT /api/v1/orders/:id - Update an order by ID
  • GET /api/v1/orders/showallmyorders - get all orders of the current user

Auth

  • POST /api/v1/auth/login - login user
  • POST /api/v1/auth/register - Create a new user

Contributing

Contributions are welcome! If you find any issues or want to add new features, feel free to open a pull request. Please ensure that your code adheres to the established coding standards and includes appropriate tests.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published