feat(server): custom base path for requests in standalone adapter#6454
Conversation
|
Warning Rate limit exceeded@KATT has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 0 minutes and 1 seconds before requesting another review. β How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. π¦ How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. π Files selected for processing (4)
WalkthroughThe pull request refactors type definitions and updates functions across both HTTP and HTTP2 adapters to support a configurable request pathname. The changes include restructuring the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant HTTPServer
participant Handler
participant Router
Client->>HTTPServer: Send request with URL
HTTPServer->>Handler: Forward request
alt URL matches custom pathname
Handler->>Router: Process request
Router-->>Handler: Return response data
Handler-->>HTTPServer: Send success response
else URL does not match
Handler-->>HTTPServer: Send 404 error
end
HTTPServer-->>Client: Deliver response
Assessment against linked issues
Poem
πͺ§ 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 (
|
|
π Previously deployed to Railway in the trpc-sse-and-websockets project. Environment has been deleted. |
|
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
commit: |
There was a problem hiding this comment.
Actionable comments posted: 0
π§Ή Nitpick comments (3)
packages/server/src/adapters/standalone.ts (1)
62-70: Consider handling trailing slash edge case.The implementation correctly handles the pathname slicing, but it might be good to handle the case where users forget to include the trailing slash.
- const sliceLength = opts.pathname?.length ?? 1; + const pathname = opts.pathname?.endsWith('/') ? opts.pathname : `${opts.pathname}/`; + const sliceLength = pathname?.length ?? 1;www/docs/server/adapters/standalone.md (1)
138-138: Fix grammar in heading.Change "an Custom HTTP server" to "a Custom HTTP server".
-## Adding a handler to an Custom HTTP server +## Adding a handler to a Custom HTTP serverπ§° Tools
πͺ LanguageTool
[misspelling] ~138-~138: Use βaβ instead of βanβ if the following word doesnβt start with a vowel sound, e.g.Β βa sentenceβ, βa universityβ.
Context: ...ver (see below) ## Adding a handler to an Custom HTTP servercreateHTTPServer...(EN_A_VS_AN)
www/docs/migration/migrate-from-v10-to-v11.mdx (1)
27-32: Improve Section Title and Clarify Behavior for CustompathnameOptionThe new section clearly documents the addition of the custom
pathnameoption for the standalone adapter. However, the section title wording ("Custompathnameto handle requests under in the standalone adapter") is a bit awkward. Consider rephrasing it for clarity. For example, change it to:-### Custom `pathname` to handle requests under in the standalone adapter (non-breaking) +### Custom `pathname` option for standalone adapter (non-breaking)Additionally, while the description ("The standalone adapter now supports a
pathnameoption, which will slice the pathname from the beginning of the request path.") is clear, it might be helpful to briefly explain what "slicing" means in practice or include a reference to an example (if not already covered in the linked docs).
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (5)
packages/server/src/adapters/node-http/types.ts(1 hunks)packages/server/src/adapters/standalone.ts(3 hunks)packages/tests/server/adapters/standalone.http2.test.ts(5 hunks)www/docs/migration/migrate-from-v10-to-v11.mdx(1 hunks)www/docs/server/adapters/standalone.md(4 hunks)
π§° Additional context used
πͺ LanguageTool
www/docs/server/adapters/standalone.md
[misspelling] ~138-~138: Use βaβ instead of βanβ if the following word doesnβt start with a vowel sound, e.g.Β βa sentenceβ, βa universityβ.
Context: ...ver (see below) ## Adding a handler to an Custom HTTP server createHTTPServer ...
(EN_A_VS_AN)
β° Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: E2E-tests (tanstack-start)
π Additional comments (4)
packages/server/src/adapters/standalone.ts (1)
30-44: LGTM! Well-documented type definition.The
StandaloneHandlerOptionstype is well-structured with clear documentation, examples, and default value specification.packages/server/src/adapters/node-http/types.ts (1)
107-119: LGTM! Clean type restructuring.The type extension is well-organized and the
pathproperty is properly documented.packages/tests/server/adapters/standalone.http2.test.ts (1)
179-218: LGTM! Comprehensive test coverage for custom pathname.The test case thoroughly verifies:
- 404 handling for undefined paths
- Correct URL construction with custom pathname
- Proper request handling under the custom path
www/docs/server/adapters/standalone.md (1)
164-187: LGTM! Clear documentation for custom pathname feature.The documentation clearly explains the pathname feature with a practical example.
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
Closes #5078
π― Changes
What changes are made in this PR? Is it a feature or a bug fix?
β Checklist
Summary by CodeRabbit
New Features
Documentation