feat(server): improve standard apis#290
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes refactor several modules by simplifying parameter handling and centralizing request/response details into a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Handler as StandardHandler
participant Proc as ProcedureClient
Client->>Handler: Call intercept(request, context, prefix)
Handler->>Handler: Destructure parameters directly
Handler->>Proc: Call createProcedureClient(context)
alt Error Occurs
Handler->>Handler: Check if isDecoding and error not ORPCError
Handler-->>Client: Return error response
else Success
Handler-->>Client: Return normal response
end
sequenceDiagram
participant Adapter
participant RequestFn as toStandardLazyRequest
participant RawObj
Adapter->>RequestFn: Pass request (from fetch/node)
RequestFn->>RawObj: Create raw object { adapter: 'fetch'/'node', request, [response] }
RequestFn->>RequestFn: Update body & headers from raw.request/response
RequestFn-->>Adapter: Return StandardLazyRequest object with new structure
Possibly related PRs
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/openapi
@orpc/openapi-client
@orpc/server
@orpc/react-query
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/svelte-query
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/server/src/adapters/standard/handler.test.ts (1)
38-38: Consider using 'unknown' for adapter instead of empty string for consistency.While the change correctly adds the adapter property to the raw object, other similar changes in the codebase use 'unknown' as the value instead of an empty string. Consider standardizing this value for better consistency.
- raw: { adapter: '' }, + raw: { adapter: 'unknown' },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/client/src/adapters/standard/rpc-link-codec.test.ts(5 hunks)packages/openapi/src/adapters/node/openapi-handler.test.ts(1 hunks)packages/openapi/src/adapters/standard/openapi-codec.test.ts(4 hunks)packages/server/src/adapters/node/rpc-handler.test.ts(1 hunks)packages/server/src/adapters/standard/handler.test.ts(1 hunks)packages/server/src/adapters/standard/rpc-codec.test.ts(2 hunks)
🔇 Additional comments (13)
packages/server/src/adapters/standard/rpc-codec.test.ts (2)
25-25: Update to request structure for GET method test.The change adds an
adapterproperty to therawobject in the request, aligning with the refactoring mentioned in the PR that centralizes request/response details into arawvariable with anadapterproperty.
48-48: Update to request structure for non-GET method test.Similar to the GET method test, this change adds an
adapterproperty to therawobject, maintaining consistency across different request methods. The change ensures test compatibility with the updated structure of request objects in the codebase.packages/openapi/src/adapters/node/openapi-handler.test.ts (1)
40-50: Update to standardRequest.raw looks good!This change aligns the test with the broader PR objectives of centralizing request/response details into a
rawvariable with anadapterproperty. Using the value'unknown'is appropriate for this test context.packages/server/src/adapters/node/rpc-handler.test.ts (1)
42-42: LGTM! The adapter property has been consistently added to the raw object.This change aligns with the broader effort to standardize the request/response structure by including adapter information in the
rawproperty. Now the tests accurately reflect that the adapter is identified as 'unknown' for test requests.packages/openapi/src/adapters/standard/openapi-codec.test.ts (4)
27-27: LGTM! Consistently added adapter information to the raw property.The change standardizes the test request structure by including the adapter type, which aligns with other similar changes throughout the codebase.
47-47: LGTM! Consistently added adapter information to the raw property.The update ensures the test properly includes adapter type in the request structure for the non-GET method test case.
77-77: LGTM! Consistently added adapter information to the raw property.This change continues the pattern of standardizing request structures by adding the adapter property for the detailed structure GET method test.
108-108: LGTM! Consistently added adapter information to the raw property.The adapter property has been properly added to the raw object for the non-GET method with detailed structure test.
packages/client/src/adapters/standard/rpc-link-codec.test.ts (5)
138-138: LGTM! Consistently added adapter information to the raw property.The adapter property has been properly added to the output decoding test case, which aligns with the standardization changes across the codebase.
160-160: LGTM! Consistently added adapter information to the raw property.The adapter property has been properly added to the error decoding test case, following the same pattern as other changes.
176-176: LGTM! Consistently added adapter information to the raw property.The adapter property has been correctly added to the test for error handling when parsing response body fails.
189-189: LGTM! Consistently added adapter information to the raw property.The adapter property has been correctly added to the test for invalid RPC response format, maintaining consistency with other changes.
212-212: LGTM! Consistently added adapter information to the raw property.The adapter property has been properly added to the test for invalid RPC error response format, completing the standardization of the raw property structure.
Summary by CodeRabbit
Refactor
rawproperty in request and response objects to include adapter information.Tests