v1.1.2
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
- Clone the repository
git clone https://github.com/iamberk/ecommerce-api
- Install dependencies
npm install
- 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"
- Run the app
npm start
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 /api/v1/get-users
GET /api/v1/get-user/:id
GET /api/v1/me
- Headher: Authorization: Bearer ${token}
POST /api/v1/register
- Body: firstname, lastname, pronounce, email, password
POST /api/v1/login
- Body: email, password
PATCH /api/v1/update-user/:id
- Body: password, firstname, lastname
DELETE /api/v1/delete-user/:id
In this version, category feature is not included. It will be added in the next versions.
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 /api/v1/get-products
GET /api/v1/get-product/:id
POST /api/v1/create-product
- Body: name, description, image, category
PATCH /api/v1/update-product/:id
- Body: name, description, image, category
DELETE /api/v1/delete-product/:id
In this version, order feature is not included. It will be added in the next versions.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
ISC