Repository navigation
feat(013-gen-endpoint-command): implement gen endpoint command - #16
Merged
Merged
Conversation
Introduces the `nfw gen endpoint` CLI command to automate the generation of Minimal API HTTP endpoints for existing MediatR commands and queries. Key changes: - Added `GenEndpointCommand` and its handler to the application layer. - Implemented CLI command registration and handler in the presentation layer. - Added a new Tera template for endpoint generation. - Enhanced `TemplateConfig` to support `mediator_sources`, allowing generators to declare which artifact types they can attach to. - Refactored `ArtifactGenerationService` and `TemplateEngine` to use template-driven path resolution instead of hardcoded directory patterns. - Added comprehensive integration tests for endpoint generation, including validation of existing mediator artifacts and error handling.
…command validation Refactors `WorkspaceContext` and `AddArtifactContext` to use private fields with accessor methods, improving encapsulation and ensuring data integrity through constructor-based validation. Key changes include: - Implementing `WorkspaceContext::new` with directory existence checks. - Implementing `AddArtifactContext::new` with parameter validation. - Updating `GenEndpointCommand` to use a typed `HttpMethod` enum instead of raw strings, including `FromStr` implementation. - Refactoring various command handlers (`AddMediator`, `AddPersistence`, `AddWebApi`, `GenRepository`) to use the new accessor pattern. - Updating CLI handlers and integration tests to accommodate the new encapsulated API and improved error handling.
…ommand - Implement `get_mediator_items` to support discovery of commands and queries. - Refactor `ArtifactGenerationService` to improve feature root derivation and directory traversal error handling. - Update `GenEndpointCommandHandler` visibility and improve test coverage for template resolution and mediator item extraction. - Add constants for generator types (`command`, `query`, `webapi`). - Fix path safety check to be case-insensitive in integration tests. - Update `FileSystemTemplateEngine` to use a new instance of `TeraTemplateRenderer`.
- Extract "Common" string literal into `DEFAULT_FEATURE_NAME` within the generation constants module. - Update `GenEndpointCommandHandler` to utilize the new constant for fallback feature naming.
… generation - Update `ArtifactGenerationService::list_features` to aggregate features from all derived roots using a `HashSet`. - Ensure feature list is sorted and unique. - Fix import order in `GenEndpointCommandHandler`.
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.
🚀 Motivation and Context
Implement a new
gen endpointcommand for the template management system. This command generates endpoint artifacts for N-Layer architecture templates, including handler, request DTO, response DTO, and service registration files.⚙️ Implementation Details
Core Changes:
GenEndpointCommandandGenEndpointCommandHandlerin the application layersrc/commands/gen/endpoint/handler.rsTemplate System Enhancements:
ArtifactGenerationServicewith endpoint-specific rendering logicTemplateEngineto handle endpoint template contextTemplateConfigto support endpoint configurationTesting:
GenEndpointCommandHandler(11 test cases)gen_endpoint_test.rs(success scenarios)📋 Checklist for Reviewer
🔗 Related
No related issues or PRs.