Warning
Profe lea el chat de plataforma para las variables de entorno
Important
Levantar el proyecto usando este esquema de variables de entorno:
.env.dev
PORT=8080
URI_MONGODB=mongodb://localhost:27017/"colocar un nombre a la base de datos"
FRONTEND_DEV_URL=http://localhost:3000
COOKIE_SIGN=
JWT_PRIVATE_KEY=
JWT_EXPIRES_IN=
MAIL_SERVICE=gmail
MAIL_PORT=587
MAIL_FROM=
MAIL_PASS=
MAIL_HOST=smtp.gmail.com
.env.prod
PORT=8080
URI_MONGODB="la url de mongo atlas"
FRONTEND_DEV_URL=http://localhost:3000
COOKIE_SIGN=
JWT_PRIVATE_KEY=
JWT_EXPIRES_IN=
MAIL_SERVICE=gmail
MAIL_PORT=587
MAIL_FROM=
MAIL_PASS=
MAIL_HOST=smtp.gmail.com
- POST
/auth/register- Role: PUBLIC
- Request Body:
{ "first_name": "John", "last_name": "Doe", "email": "john@example.com", //Profe porfa coloque un mail valido para que compruebe que le llegue el email. "age": 25, "password": "password123", "role": "USER" // Optional, defaults to "USER" }
- POST
/auth/login- Role: PUBLIC
- Request Body:
{ "email": "john@example.com", "password": "password123" }
- POST
/auth/logout- Role: USER, ADMIN
- Clears the authentication token
- GET
/products/- Role: PUBLIC
- Query Parameters:
limit: Number of items per page (default: 10)page: Page number (default: 1)sort: Sort order ('asc' or 'desc')query: Search query string
- GET
/products/detail/:slug- Role: PUBLIC
- Example:
/products/detail/example-product
- POST
/products/createProduct- Role: ADMIN
- Request Body:
{ "title": "New Product", "description": "Product description", "price": 99.99, "stock": 100, "category": "electronics", "imageUrl": "[http://example.com/image.jpg"](http://example.com/image.jpg") }
- PUT
/products/detail/:slug- Role: ADMIN
- Request Body: (include only fields to update)
{ "price": 89.99, "stock": 90 }
- DELETE
/products/detail/:slug- Role: ADMIN
- GET
/cart/:cid- Role: USER, ADMIN
- Returns the cart with all products
- POST
/cart/:cid/products/:pid- Role: USER, ADMIN
- Request Body:
{ "quantity": 1 }
- PUT
/cart/:cid/products/:pid- Role: USER, ADMIN
- Request Body:
{ "quantity": 3 }
- DELETE
/cart/:cid/products/:pid- Role: USER, ADMIN
- DELETE
/cart/:cid- Role: USER, ADMIN
- POST
/cart/:cid/purchase- Role: USER, ADMIN
- The logic is in the services but basically you need to send in the request body the email and then the service update the stock if it's enough. The validation sends only the products that had stock and the outOfStock items remain on the cart.
- Returns order details and send the email to the user with the order.
- GET
/user/current- Role: USER, ADMIN
- Returns the currently authenticated user's profile
- GET
/user/- Role: PUBLIC
- Returns a welcome message and API status