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.
Before running the application, make sure you have the following installed:
- Node.js (v14 or higher)
- MongoDB
- Clone the repository:
git clone https://github.com/cannonmaster/express-mongo-ecommerce-api.git
- Navigate to the project directory:
cd express-mongo-ecommerce-api
- Install the dependencies:
npm install
-
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 theexample.env
file for the required variables.
- Create a
-
Start the application:
npm start
The API server will start running on http://localhost:3000
.
GET /api/v1/products
- Get all productsGET /api/products/:id
- Get a single product by IDPOST /api/v1/products
- Create a new productPATCH /api/v1/products/:id
- Update a product by IDDELETE /api/v1/products/:id
- Delete a product by ID
GET /api/v1/users
- Get all usersGET /api/v1/users/:id
- Get a single user by IDGET /api/v1/users/showMe
- Get current userPATCH /api/v1/users/updateUser
- Update a user by IDPATCH /api/v1/users/updateUserPassword
- Update a user password
GET /api/v1/reviews
- Get all reviewsGET /api/v1/reviews/:id
- Get a single reviewPOST /api/v1/reviews
- Create a new reviewPATCH /api/v1/reviews/:id
- Update an reviewDELETE /api/v1/reviews/:id
- delete all reviews
GET /api/orders
- Get all ordersGET /api/orders/:id
- Get a single order by IDPOST /api/v1/orders
- Create a new orderPUT /api/v1/orders/:id
- Update an order by IDGET /api/v1/orders/showallmyorders
- get all orders of the current user
POST /api/v1/auth/login
- login userPOST /api/v1/auth/register
- Create a new user
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.
This project is licensed under the MIT License.