Improve Agreement Router reliability, validation consistency, and template handling - #151
Improve Agreement Router reliability, validation consistency, and template handling#151muralimadhava96-ui wants to merge 3 commits into
Conversation
|
Hi maintainers 👋 This PR focuses on improving Agreement API reliability by:
I’d really appreciate your feedback on whether this direction aligns with the project’s testing and API design approach. Especially curious about: Thanks! |
…on, and safer state handling Refactored the Agreement router to improve code quality, maintainability, and production readiness. Key improvements: - Introduced service-level abstraction (getTemplate, resolveAgreement) to reduce duplication and improve separation of concerns - Added strict ID parsing with validation to prevent invalid database queries - Improved error handling with consistent responses and removed internal error leakage - Integrated structured logging using pino instead of console logs - Simplified template retrieval and caching logic - Ensured safer database updates by avoiding full object mutation (partial state update only) - Cleaned up validation flow combining Zod schema and Concerto validation - Reduced branching complexity and improved readability This refactor aligns the codebase with production-grade backend practices and prepares it for future extensibility (e.g., additional template retrievers, auth middleware, and rate limiting). Future work: - Add authentication and authorization middleware - Implement rate limiting for trigger endpoints - Replace `any` types with strict Drizzle ORM typings - Add unit and integration tests Signed-off-by: muralimadhava96-ui <muralimadhava96@gmail.com>
…proved structure test(apap): refactor agreement API tests with simplified mocks Signed-off-by: muralimadhava <muralimadhava96@gmail.com> Signed-off-by: muralimadhava96-ui <muralimadhava96@gmail.com>
…dling and validation feat(apap): improve agreement API reliability, validation consistency, and error handling Signed-off-by: muralimadhava <muralimadhava96@gmail.com> Signed-off-by: muralimadhava96-ui <muralimadhava96@gmail.com>
3ce986a to
903588f
Compare
|
This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
This PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed. |
|
This PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed. |
|
Wanted to flag before you invest in a rebase. A rebase now will surface heavy conflicts, and the diff shape will change substantially. Worth reassessing which of the improvements are still relevant against current |
|
Thanks @muralimadhava96-ui for the original direction here. Closing this out because the reliability, validation, and template-handling intent has landed on Coverage on
Closing rather than rebasing because the underlying router shape this PR targets no longer exists on Credit for surfacing the original set of concerns stays with you. |
Overview
This PR refactors the Agreement router to improve code structure, validation robustness, and execution safety. It also introduces comprehensive test coverage for agreement execution, template handling, and error scenarios.
The goal is to align the implementation with production-grade backend practices while ensuring reliability and maintainability.
-->Architecture & Maintainability
--> Validation Enhancements
--> Safer Execution
--> Template Handling
--> Logging
-->Added comprehensive tests covering:
-->Test improvements:
--> Behavior Changes
--> Performance
--> Compatibility
--> Future Work
anytypes with strict typings--> Motivation
This refactor improves reliability, maintainability, and developer experience while preparing the codebase for future scalability and extensibility. The addition of strong test coverage ensures confidence in agreement execution and template processing workflows.