A simple e-commerce API built with NestJS and TypeORM.
- URL:
/auth/register - Method:
POST - Description: Register a new user account
- Payload:
{ "name": "string", "email": "string (valid email format)", "password": "string (min length: 6)" } - Response: User information and authentication token
- Authentication Required: No
- URL:
/auth/login - Method:
POST - Description: Authenticate a user and receive a token
- Payload:
{ "email": "string (valid email format)", "password": "string" } - Response: Authentication token and user information
- Authentication Required: No
- URL:
/auth/profile - Method:
GET - Description: Retrieve authenticated user's profile information
- Response:
{ "message": "Profile accessed successfully" } - Authentication Required: Yes
- URL:
/products - Method:
GET - Description: Retrieve a list of all products, optionally filtered by category
- Query Parameters:
category(optional): Filter products by category
- Response: Array of product objects
- Authentication Required: No
- URL:
/products/:id - Method:
GET - Description: Retrieve detailed information about a specific product
- URL Parameters:
id: UUID of the product
- Response: Product object details
- Authentication Required: No
- URL:
/cart - Method:
GET - Description: Retrieve the current user's shopping cart
- Response: User's cart with items
- Authentication Required: Yes
- URL:
/cart/add - Method:
POST - Description: Add a product to the user's shopping cart
- Payload:
{ "productId": "string (UUID)", "quantity": "number (min: 1)" } - Response: Updated cart information
- Authentication Required: Yes
- URL:
/cart/:id - Method:
PUT - Description: Update the quantity of an item in the cart
- URL Parameters:
id: UUID of the cart item
- Payload:
{ "quantity": "number (min: 1)" } - Response: Updated cart information
- Authentication Required: Yes
- URL:
/cart/:id - Method:
DELETE - Description: Remove a specific item from the cart
- URL Parameters:
id: UUID of the cart item
- Response: Updated cart information
- Authentication Required: Yes
- URL:
/cart - Method:
DELETE - Description: Remove all items from the user's cart
- Response: Confirmation of cart clearing
- Authentication Required: Yes
- URL:
/orders - Method:
POST - Description: Create a new order using the items in the user's cart
- Payload:
{ "shippingAddress": "string", "paymentMethod": "string" } - Response: Order details
- Authentication Required: Yes
- URL:
/orders - Method:
GET - Description: Retrieve a list of all orders placed by the current user
- Response: Array of user's orders
- Authentication Required: Yes
- URL:
/orders/:id - Method:
GET - Description: Retrieve detailed information about a specific order
- URL Parameters:
id: UUID of the order
- Response: Order details
- Authentication Required: Yes
- URL:
/ - Method:
GET - Description: Simple hello message from the API
- Response: Hello message
- Authentication Required: No
The application automatically seeds the database with sample products if no products exist when the server starts.
The following products are seeded on application startup:
-
Smartphone X
- Description: Latest smartphone with advanced features
- Price: $999.99
- Category: Electronics
-
Running Shoes
- Description: Comfortable running shoes for professional athletes
- Price: $129.99
- Category: Sports
-
Coffee Maker
- Description: Automatic coffee maker with timer
- Price: $89.99
- Category: Home
-
Laptop Pro
- Description: High-performance laptop for professionals
- Price: $1499.99
- Category: Electronics
-
Wireless Earbuds
- Description: Premium wireless earbuds with noise cancellation
- Price: $199.99
- Category: Electronics
- Product seeding occurs automatically on application startup
- Seeding is skipped if products already exist in the database
- Seeding logs are visible in the server console
All endpoints that require authentication expect a valid authentication token in the Authorization header. The token can be obtained through the login endpoint.
Format: Authorization: Bearer <token>