This is an E-commerce API built using Node.js and Express. The API provides functionalities for product management, cart management, order placement, authentication, and authorization. Data is persisted using Supabase.
- Installation
- Usage
- API Endpoints
- Error Handling
- Swagger Documentation
- Deployment
- Contributing
- License
-
Clone the repository:
git clone https://github.com/your-username/ecommerce-api.git cd ecommerce-api
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.env
file in the root of the project and add the following variables:SUPABASE_URL=your-supabase-url SUPABASE_KEY=your-supabase-key JWT_SECRET=your-jwt-secret
-
Initialize the database schema in Supabase:
Create the necessary tables in your Supabase project:
- Users
- Products
- Carts
- CartItems
- Orders
- OrderItems
-
Start the server:
npm start
-
The API will be available at
http://localhost:3000
.
The API is deployed on Railway Cloud and can be accessed at: https://e-commerce-api-production-dc2f.up.railway.app
The API uses centralized error handling middleware to return appropriate HTTP status codes and error messages for different scenarios. Custom error classes are used to represent different error types.
The API is documented using Swagger. You can access the Swagger UI at http://localhost:3000/api-docs
.
-
Build the Docker image:
docker build -t ecommerce-api .
-
Run the Docker container:
docker run -p 3000:3000 -d ecommerce-api
- Push the Docker image to a container registry.
- Set up a new project on Railway.
- Configure environment variables on Railway.
- Deploy the Docker image from the container registry.
Contributions are welcome! Please open an issue or submit a pull request with your improvements.
This project is licensed under the MIT License. See the LICENSE file for details.