Closed
[WIP] Implement improvements to validation, context, health, and error handling#11
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.
Original prompt
Mejoras de Framework: Validación, Context, Health, Errores y Request ID
Objetivo
Implementar mejoras fundamentales en el framework Medusa para mejorar la Developer Experience y mantener la filosofía "Batteries Included, Decisions Optional".
Problemas a Resolver
1. Validación Inconsistente
Problema Actual:
binding:"required,email")validator.ValidationErrorsSolución:
ErrorValidationque formatee errores de validatorArchivos a modificar:
internal/dto/auth.go- Agregar tags bindingpkg/medusa/core/responses/validation.go- NUEVO archivo con helpersinternal/handlers/auth.go- Usar nuevo helper2. Medusa Context Wrapper
Problema Actual:
Solución:
pkg/medusa/context.gocon wrapper sobregin.ContextGetUserID(),MustGetUserID(),BindJSON(),GetParamUint()OK(),Created(),BadRequest(),NotFound()Archivos nuevos:
pkg/medusa/context.go- Context principalpkg/medusa/context_user.go- Helpers de autenticaciónpkg/medusa/context_binding.go- Helpers de binding/validaciónpkg/medusa/context_response.go- Helpers de respuestaspkg/medusa/constants.go- Constantes de context keyspkg/medusa/middleware/context.go- Middleware de inyección3. Health Checks Básicos
Problema Actual:
/healthque retorna "ok"/health/readyy/health/live(Kubernetes)Solución:
Archivos nuevos:
pkg/medusa/core/health/health.go- Sistema de health checkspkg/medusa/core/health/checkers.go- Checkers predefinidospkg/medusa/core/handler/health.go- ACTUALIZAR con nuevos endpoints4. Manejo de Errores Mejorado
Problema Actual:
VALIDATION_ERRORSolución:
VALIDATION_ERRORerror codeArchivos a modificar:
pkg/medusa/core/responses/error.go- Agregar VALIDATION_ERRORpkg/medusa/core/responses/validation.go- NUEVO con formateo5. Request ID Middleware
Problema Actual:
Solución:
RequestIDContextKeyArchivos nuevos:
pkg/medusa/middleware/request_id.go- Middlewarepkg/medusa/context.goconGetRequestID()6. Handlers Genéricos/Base
Problema Actual:
Solución:
pkg/medusa/core/handler/handler.goImplementación
Estructura de Archivos Nuevos
Filosofía de Diseño
IMPORTANTE: Mantener la filosofía "Batteries Included, Decisions Optional"
✅ SÍ hacer:
❌ NO hacer:
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.