Conversation
…rd compatibility.
…ward compatibility.
WalkthroughRenames the contextual argument across the codebase from options to ctx and updates related types, signatures, and usages. EndpointsFactory.addOptions is renamed to addContext. Core endpoint/middleware flow, tests, examples, docs, and migration rules are updated accordingly. No functional logic changes; interface and parameter names are standardized. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor C as Client
participant S as Server
participant E as Endpoint
participant M as Middlewares
participant H as Handler
participant R as ResultHandler
C->>S: HTTP Request
S->>E: route match(request)
E->>M: execute(request, ctx = {})
loop each middleware
M-->>E: merge into ctx
end
E->>H: handler({ input, request, response, logger, ctx })
H-->>E: result or throws
alt success
E->>R: execute({ input, ctx, ... })
R-->>S: send response
else error
E->>R: execute({ input: null, ctx, ... })
R-->>S: send error response
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai, review |
|
@RobinTail I'll review the changes in this PR about renaming ✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
dataflow.svgis excluded by!**/*.svg
📒 Files selected for processing (21)
CHANGELOG.md(1 hunks)README.md(11 hunks)example/endpoints/retrieve-user.ts(1 hunks)example/endpoints/time-subscription.ts(1 hunks)example/endpoints/update-user.ts(1 hunks)express-zod-api/src/endpoint.ts(12 hunks)express-zod-api/src/endpoints-factory.ts(8 hunks)express-zod-api/src/middleware.ts(5 hunks)express-zod-api/src/result-handler.ts(1 hunks)express-zod-api/src/server-helpers.ts(2 hunks)express-zod-api/src/testing.ts(2 hunks)express-zod-api/tests/endpoint.spec.ts(5 hunks)express-zod-api/tests/endpoints-factory.spec.ts(3 hunks)express-zod-api/tests/middleware.spec.ts(2 hunks)express-zod-api/tests/result-handler.spec.ts(5 hunks)express-zod-api/tests/routing.spec.ts(1 hunks)express-zod-api/tests/sse.spec.ts(3 hunks)express-zod-api/tests/system.spec.ts(3 hunks)express-zod-api/tests/testing.spec.ts(1 hunks)migration/index.spec.ts(2 hunks)migration/index.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-06-14T16:42:52.972Z
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2736
File: express-zod-api/tsup.config.ts:12-26
Timestamp: 2025-06-14T16:42:52.972Z
Learning: In express-zod-api tsup configurations, the direct mutation of `options.supported` in the `esbuildOptions` callback is intentional behavior and should not be flagged as a side effect issue.
Applied to files:
express-zod-api/tests/routing.spec.tsexpress-zod-api/tests/result-handler.spec.tsexpress-zod-api/tests/testing.spec.tsexpress-zod-api/src/server-helpers.tsexpress-zod-api/tests/endpoint.spec.tsexpress-zod-api/src/testing.tsexpress-zod-api/tests/middleware.spec.tsexpress-zod-api/tests/system.spec.tsexpress-zod-api/tests/sse.spec.ts
📚 Learning: 2025-05-28T07:58:09.853Z
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/src/documentation-helpers.ts:508-512
Timestamp: 2025-05-28T07:58:09.853Z
Learning: In express-zod-api, when working with Zod's JSON schema override callbacks, using `delete` to mutate `ctx.jsonSchema` is the recommended approach per Zod's official documentation, even if it triggers performance linting warnings. This is preferable to creating copies with `undefined` values, especially for snapshot testing.
Applied to files:
express-zod-api/tests/testing.spec.tsexpress-zod-api/tests/endpoint.spec.tsexpress-zod-api/src/testing.tsexpress-zod-api/tests/system.spec.ts
📚 Learning: 2025-05-27T19:35:57.357Z
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2546
File: express-zod-api/tests/buffer-schema.spec.ts:32-37
Timestamp: 2025-05-27T19:35:57.357Z
Learning: In the express-zod-api project, tests are run from the `express-zod-api` workspace directory, and the project uses an ESM-first environment without `__dirname`. Relative paths like `../logo.svg` in test files correctly resolve to the repository root due to this test execution context.
Applied to files:
express-zod-api/tests/endpoint.spec.ts
📚 Learning: 2025-06-02T21:08:56.475Z
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2697
File: CHANGELOG.md:5-5
Timestamp: 2025-06-02T21:08:56.475Z
Learning: The `cjs-test` directory in the express-zod-api repository is a test workspace and should be excluded when checking for main project version consistency with changelog entries.
Applied to files:
express-zod-api/tests/endpoint.spec.ts
📚 Learning: 2025-08-25T17:43:34.491Z
Learnt from: RobinTail
PR: RobinTail/express-zod-api#2904
File: express-zod-api/src/routing.ts:74-79
Timestamp: 2025-08-25T17:43:34.491Z
Learning: In express-zod-api, OPTIONS (CORS preflight) requests intentionally go through the same middleware and parser chain as other HTTP methods. This was specifically implemented to fix Issue #514 where middlewares were not running for OPTIONS requests. The framework seeds "options" with the same [parsers, endpoint] pair as other methods to ensure consistent middleware execution for CORS preflight requests.
Applied to files:
express-zod-api/tests/middleware.spec.tsexpress-zod-api/tests/system.spec.tsREADME.mdexpress-zod-api/src/endpoint.ts
🪛 Biome (2.1.2)
express-zod-api/tests/endpoints-factory.spec.ts
[error] 135-135: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
[error] 181-181: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
[error] 207-207: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
[error] 207-207: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
[error] 224-224: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
[error] 224-224: Unexpected empty object pattern.
(lint/correctness/noEmptyPattern)
🔇 Additional comments (25)
example/endpoints/retrieve-user.ts (1)
34-55: Rename aligns the handler with the new context APISwitching to
ctxkeeps the destructuring in sync with the middleware changes and preserves runtime behavior. Looks good.migration/index.spec.ts (1)
21-159: Great migration coverageThese new fixtures capture the key
options→ctxmigration patterns (plain, aliased, and nested destructuring, plus method rename). The rule set should now confidently nudge consumers onto the new API.example/endpoints/time-subscription.ts (1)
15-23: Context rename looks correctAccessing
emit/isClosedviactxmirrors the surrounding refactor without altering the stream loop behavior. All good.example/endpoints/update-user.ts (1)
33-41: Context destructuring stays consistentPicking
authorizedfromctxmatches the new factory surface and keeps the handler logic intact.CHANGELOG.md (1)
8-13: Changelog entry reads wellThe note clearly communicates the breaking rename and touches every affected surface. No further tweaks needed.
migration/index.ts (1)
121-143: Selectors and fixers line up with the ctx renameThe new handlers cover the critical AST shapes for renaming
options→ctxandaddOptions→addContext, and the fixes stay safely scoped to the identifiers you match. Looks solid.express-zod-api/tests/routing.spec.ts (1)
502-505: Test arguments reflect the ctx contractThe expectations now mirror the updated handler signature by asserting an empty
ctx. Thanks for keeping the verification aligned with the public API change.express-zod-api/tests/testing.spec.ts (1)
64-76: Middleware test updated correctlySwapping the fixture input and assertions to
ctxkeeps the helper contract in sync with the rename. Nice and tidy.express-zod-api/tests/result-handler.spec.ts (1)
94-228: Result handler exercises now track ctx flawlesslyEvery
executeinvocation and related expectation moved over toctx, so the suite continues to validate the handler interface without gaps. Great work.express-zod-api/src/server-helpers.ts (1)
40-64: Server error helpers now pass ctxForwarding an empty
ctxkeeps the helper utilities compatible with the refactoredResultHandlersignature. All consistent.express-zod-api/src/testing.ts (1)
123-129: Rename to ctx is consistent and correct.Parameter rename and propagation through commons look good.
Also applies to: 143-144
express-zod-api/src/result-handler.ts (1)
26-26: Handler param rename to ctx looks good.Type contract remains clear and consistent with call sites.
express-zod-api/tests/sse.spec.ts (1)
79-79: SSE tests aligned to ctx.Type expectations and handler destructuring updated correctly.
Also applies to: 121-121, 156-161
express-zod-api/tests/middleware.spec.ts (1)
48-49: Middleware tests updated to ctx.Invocation and assertions are consistent with the new API.
Also applies to: 68-68, 76-76
express-zod-api/tests/endpoints-factory.spec.ts (2)
57-67: Context chaining assertions are correct.Type-level checks on ctx propagation are sound.
104-117: addContext test reads clean and types match expectations.API rename and resulting factory type are correct.
express-zod-api/src/middleware.ts (4)
10-24: Consistent handler signature renameThe switch to
ctxthroughout the handler contract is clean and keeps the intent of the argument obvious without altering behavior. Looks good to me.
31-37: Base execute contract stays alignedRenaming the abstract execution payload to
ctxkeeps the public surface in sync with the rest of the refactor while preserving the same type guarantees. No issues spotted here.
41-105: Middleware generics and flow remain soundThe generic rename to
CTX/RET, handler wiring, and theexecuteimplementation all track the new terminology without introducing behavioral changes. Everything continues to type-check againstFlatObjectas before.
108-133: Express wrapper matches the new context shape
ExpressMiddlewarenow forwards and resolvesctxunder the updated naming, and the default provider still yields a valid flat object. This section looks solid.express-zod-api/tests/endpoint.spec.ts (1)
49-50: Tests now mirror the ctx-based handler contractThanks for updating the test doubles and assertions to expect
ctx. This keeps the test suite acting as a strong guardrail for the rename.Also applies to: 74-85, 92-93
express-zod-api/tests/system.spec.ts (1)
38-39: End-to-end coverage follows the ctx terminologyThe system spec still walks the full request lifecycle and now exercises the ctx plumbing, which is exactly what we need to catch regressions in real usage.
Also applies to: 78-81, 88-99
README.md (1)
22-24: Documentation refresh is thoroughThe renaming is reflected across the table of contents, narrative explanation, and examples, so developers reading the guide will stay in sync with the API.
Also applies to: 149-231, 383-414
express-zod-api/src/endpoint.ts (1)
35-40: Endpoint pipeline now consistently speaks ctxType aliases, middleware accumulation, and result handling all align on
ctx, so the runtime behavior and type surfaces stay coherent after the rename.Also applies to: 214-239, 286-333
express-zod-api/src/endpoints-factory.ts (1)
30-47: Factory API rename is clean
BuildProps, generics, and the newaddContexthelper all converge on the updated naming, which keeps consumers’ ergonomics tidy.Also applies to: 72-122, 120-122
<img width="283" height="353" alt="image" src="https://github.com/user-attachments/assets/5355c68c-e807-4b61-83a8-17e66a117f7d" /> [Lia Smith](https://en.wikipedia.org/wiki/Suicide_of_Lia_Smith) was a 21 years young transgender woman. She attended Middlebury College in Middlebury, Vermont, majoring in computer science and statistics. She was a member of the college's chess club, bridge club, LGBTQ+ club, and Japanese club. She was a diver on the Middlebury Panthers women's swimming and diving team. In February 2025 Middlebury College had removed Lia Smith diving profile from their website, following President Donald Trump's executive order, which attempts to ban transgender women and girls from competing in women's sports. On October 18, 2025 Lia Smith committed suicide. The tragedy of Lia Smith highlights that the push for exclusion of transgender women from public women's spaces and sports is not an issue of theoretical fairness, but one with devastating consequences for the dignity, safety, and lives of trans individuals. Smith, who was an openly transgender student athlete, described the immense difficulty and feeling of being unwelcome in locker rooms, emphasizing the lack of a clear, safe space for her. Her plea that transgender people are "not trying to get into women's spaces to be perverts... we're just being ourselves" underscores that inclusion is a matter of allowing trans women to exist and access necessary public facilities with basic dignity, rather than an invasion of privacy or a threat. Denying access to these spaces does not eliminate their need for them, but instead subjects them to alienation and heightened psychological distress. Furthermore, Lia's experience as a diver, where she was reportedly targeted by anti-trans websites and ultimately left her team citing difficulties, demonstrates the severe emotional and social toll of exclusion in sports. Critics of anti-trans policies explicitly linked her death by suicide to the hostile climate and constant public scrutiny and harassment directed at trans athletes. Allowing trans women to participate in women's sports and access women's facilities is therefore a vital component of protecting the mental health and physical safety of transgender people. When a society creates systems that reject a person’s identity and deny them opportunities for community, activity, and belonging—all essential parts of a functioning life—it creates an environment of intense hostility and vulnerability. Inclusion, in contrast, affirms the full humanity of trans women and is a necessary measure against the systemic discrimination that contributed to her anguish. -------------------------------- - #2938 - #3049 - #2934 - #3086 - #3087 - #3094 - ❔ #3102 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Config-driven routing behavior; Integration instances accept per-instance config. * Zod plugin adds CJS compatibility and new schema metadata helpers. * Release bumped to v26 (beta). * **Bug Fixes** * Restored Zod examples/metadata in CommonJS environments. * **Breaking Changes** * Handler/middleware parameter renamed: options → ctx. * Removed DependsOnMethod; use inline per-route objects. * EndpointsFactory.addOptions() renamed to addContext(). * **Docs** * README and CHANGELOG updated for v26 migration and examples. * **Tests** * Added CJS runtime tests and updated tests to use ctx. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
I realized that context is more clear naming for that entity, which is also the same in hono and trpc. It should also reduce the potential confusion with "config options" and
OPTIONSrequest method.However, it might not be possible to rename in without breaking changes, since it's present in public interfaces.
todo
Summary by CodeRabbit