Repository navigation
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughResumenWalkthroughSe agrega la capacidad de actualizar perfiles de entregas mediante una nueva migración Prisma que añade la columna Cambios
Diagramas de SecuenciasequenceDiagram
participant Client
participant Controller as Controlador
participant Auth as Validación
participant Service as Servicio
participant ImageSvc as Servicio de Imagen
participant DB as Base de Datos
Client->>Controller: PUT /api/deliveries/:id<br/>(perfil + avatar)
Controller->>Controller: Validar ID (numérico)
alt ID inválido
Controller->>Client: 400 Error
end
Controller->>Auth: Verificar JWT y rol
alt No autenticado
Auth->>Client: 401 No autorizado
end
alt Rol no es DELIVERY
Auth->>Client: 403 Prohibido
end
Controller->>Controller: Validar esquema Zod
alt Validación fallida
Controller->>Client: 400 Errores de validación
end
Controller->>Service: updateDeliveryProfileService(id, user, data, file)
Service->>DB: Buscar delivery por ID
alt Delivery no existe
Service->>Client: 404 No encontrado
end
Service->>Service: Verificar propiedad/rol (owner o ADMIN)
alt No es propietario
Service->>Client: 403 Prohibido
end
alt Archivo presente
Service->>ImageSvc: upsertUserImage(usuario, archivo)
ImageSvc->>ImageSvc: Procesar y cargar
alt Error en carga
ImageSvc->>Service: statusCode + mensaje
Service->>Client: statusCode Error al subir
end
end
Service->>DB: Actualizar usuario (nombre, teléfono)
Service->>DB: Actualizar delivery (vehicle_type)
Service->>DB: Obtener delivery actualizado
Service->>Client: 200 { delivery actualizado }
Esfuerzo estimado de revisión🎯 3 (Moderado) | ⏱️ ~25 minutos PRs posiblemente relacionados
Revisores sugeridos
Poema
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 30 minutes and 24 seconds.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/modules/delivery/delivery/delivery.routes.js (1)
25-25: ⚡ Quick winAlineá la autorización entre ruta y servicio.
La ruta solo habilita
ROLES.DELIVERY, pero ensrc/modules/delivery/delivery/delivery.service.jstambién se contemplaADMIN. Esa rama queda inaccesible y genera ambigüedad de negocio. Definí una sola política en ambos puntos.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/modules/delivery/delivery/delivery.routes.js` at line 25, La autorización está desalineada: la ruta router.put("/:id", authenticate, requireRole(ROLES.DELIVERY), upload.single("avatarUrl"), updateDeliveryProfile) solo permite ROLES.DELIVERY mientras que delivery.service.js acepta también ADMIN; unifica la política para evitar ramas inaccesibles: decidir si la operación debe permitir ADMIN y DELIVERY o solo DELIVERY, y aplicar la misma regla en ambos lugares (ajustar el requireRole en la ruta y/o la comprobación de roles en la función updateDeliveryProfile / el servicio correspondiente para usar la misma conjunto de roles: ROLES.DELIVERY[, ROLES.ADMIN] según la decisión).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/modules/delivery/delivery/delivery.service.js`:
- Around line 160-177: Agrupá las dos actualizaciones en una transacción de
Prisma para evitar estados parciales: en lugar de llamar prisma.users.update y
prisma.deliveries.update por separado, usá prisma.$transaction (o el callback
transaction API) y ejecutá tx.users.update({ where: { id_user: delivery.fk_user
}, data: { ...(name && { name }), ...(phone && { phone }) } }) y
tx.deliveries.update({ where: { id_delivery: deliveryId }, data: {
...(vehicleType !== undefined && { vehicle_type: vehicleType }) } }) dentro de
la misma transacción; propagá el error si la transacción falla para mantener
consistencia y no aplicar ningún cambio parcial.
---
Nitpick comments:
In `@src/modules/delivery/delivery/delivery.routes.js`:
- Line 25: La autorización está desalineada: la ruta router.put("/:id",
authenticate, requireRole(ROLES.DELIVERY), upload.single("avatarUrl"),
updateDeliveryProfile) solo permite ROLES.DELIVERY mientras que
delivery.service.js acepta también ADMIN; unifica la política para evitar ramas
inaccesibles: decidir si la operación debe permitir ADMIN y DELIVERY o solo
DELIVERY, y aplicar la misma regla en ambos lugares (ajustar el requireRole en
la ruta y/o la comprobación de roles en la función updateDeliveryProfile / el
servicio correspondiente para usar la misma conjunto de roles: ROLES.DELIVERY[,
ROLES.ADMIN] según la decisión).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b4c037f9-ebc6-4f5e-81eb-46d8f0a7ce7d
📒 Files selected for processing (7)
prisma/migrations/20260430025443_add_vehicle_type_to_delivery/migration.sqlprisma/schema.prismasrc/modules/delivery/delivery/delivery.controller.jssrc/modules/delivery/delivery/delivery.routes.jssrc/modules/delivery/delivery/delivery.service.jssrc/modules/delivery/delivery/delivery.validation.jstests/unit/delivery/delivery-profile.test.js
|



Summary by CodeRabbit
Notas de Versión