Este repositorio contiene dos aplicaciones:
backend-omniscient: API (NestJS) para gestionar Órdenes de Producción.storefront-omniscient: Frontend (Next.js) que consume la API y ofrece una UI.
- Node.js 20+ (recomendado LTS)
- pnpm, yarn o npm (ejemplos usan
yarn)
Instala dependencias en cada paquete:
# Backend
cd backend-omniscient
yarn install
# Frontend
cd ../storefront-omniscient
yarn installEn dos terminales:
# Terminal 1: Backend (puerto 3001)
cd backend-omniscient
yarn backend:dev# Terminal 2: Frontend (puerto 3000)
cd storefront-omniscient
yarn frontend:devEl frontend está configurado para reenviar las rutas /api/* al backend en http://localhost:3001/api/* mediante un rewrite definido en storefront-omniscient/next.config.ts.
Backend (backend-omniscient/package.json):
yarn backend:dev: inicia Nest en watch en el puerto 3001.yarn start: inicia Nest (puerto por defecto 3000 si no se usabackend:dev).yarn start:dev: watch mode.yarn build: compila adist/.yarn test,yarn test:e2e,yarn test:cov.
Frontend (storefront-omniscient/package.json):
yarn frontend:dev: inicia Next enhttp://localhost:3000.yarn dev: también inicia el modo dev (Turbopack).yarn buildyyarn startpara producción.yarn testpara unit tests (jsdom).
Base URL: http://localhost:3001/api
- Estados válidos de una orden:
planned,scheduled,in_progress,completed.
POST /api/production-orders
Body JSON:
{
"reference": "PO-0001",
"product": "Widget A",
"quantity": 100,
"dueDate": "2025-12-31T00:00:00.000Z"
}Respuesta 200:
{
"id": "uuid",
"reference": "PO-0001",
"product": "Widget A",
"quantity": 100,
"dueDate": "2025-12-31T00:00:00.000Z",
"status": "planned",
"createdAt": "2025-09-17T10:00:00.000Z"
}Validaciones:
reference: string no vacíoproduct: string no vacíoquantity: entero positivodueDate: string ISO de fecha
GET /api/production-orders
Query opcional:
status: filtra por estado (uno deplanned|scheduled|in_progress|completed).
Ejemplos:
GET /api/production-ordersGET /api/production-orders?status=planned
Respuesta 200:
[
{
"id": "uuid",
"reference": "PO-0001",
"product": "Widget A",
"quantity": 100,
"dueDate": "2025-12-31T00:00:00.000Z",
"status": "planned",
"createdAt": "2025-09-17T10:00:00.000Z"
}
]El frontend usa fetch contra /api/production-orders y el rewrite lo envía al backend:
- Listar:
GET /api/production-orders - Crear:
POST /api/production-orders
Código de ejemplo: storefront-omniscient/app/lib/api.ts.
- Backend:
cd backend-omniscient && yarn test - Frontend:
cd storefront-omniscient && yarn test
Backend:
cd backend-omniscient
yarn build
yarn start:prodFrontend:
cd storefront-omniscient
yarn build
yarn startAsegúrate de exponer el backend bajo /api y ajustar el destino del rewrite del frontend si el backend no corre en localhost:3001.