refactor: extract request handlers from A2AExpressApp#162
Conversation
97b3cea to
4832e2e
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request effectively refactors the Express.js request handlers out of A2AExpressApp into their own dedicated files, agent_card_handler.ts and json_rpc_handler.ts. This is a great step towards better modularity and prepares the codebase for future REST support as described. The logic has been moved without behavior changes, and A2AExpressApp is correctly updated to use these new handlers. My review includes a few minor suggestions to improve consistency and adhere to common best practices, such as using express.Router() consistently and improving code style for better readability and safety.
4832e2e to
6c75c53
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request does a great job of refactoring the Express.js handlers out of A2AExpressApp for better modularity and composability. The extraction into agentCardHandler and jsonRpcHandler is clean. However, I've identified a significant behavioral change related to middleware ordering that contradicts the goal of having no behavior changes in A2AExpressApp. I've also noted a minor issue with a leftover log message. My comments provide details on these points.
352f44e to
3eaefe1
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request does a great job of refactoring the request handling logic out of A2AExpressApp into separate, composable Express handlers. The code is well-structured and the extraction seems to correctly preserve the existing behavior. My review includes a few suggestions for improvement:
- Addressing redundant middleware application in
A2AExpressApp. - Improving the uniqueness of Server-Sent Event IDs.
- Simplifying the API of
jsonRpcHandlerto hide implementation details.
Overall, this is a solid refactoring that improves the modularity of the codebase.
# Description 1. Update README.md, sample agents and sample CLI to use new APIs introduced in #162 (extract middlewares from `A2AExpressApp`) and #198 (transport-agnostic client). 2. Mark `A2AExpressApp` and `A2AClient` as deprecated. 3. Ensure samples and TCK import via index files only to "test" that all required types are exported. 4. Consolidate all `@example` tags to use ` ```ts `.
Description
As a preparation step for REST support proposed in #142, extract Express.js handlers from
A2AExpressAppto allow assembling your own app using Express.js API directly for specifying individual paths and middlewares, rather than wrapping it inA2AExpressApp:No logic changes to existing handlers, they are moved as is. Also
A2AExpressAppis switched to use new handlers without behavior changes.Note: new functions are not exported via
index.tsyet, it will be done together with updating docs and examples once REST support is done.Re #137