Skip to content

Conversation

@ymc9
Copy link
Member

@ymc9 ymc9 commented Nov 18, 2025

Summary by CodeRabbit

  • Refactor
    • Enhanced type system for internal API handlers with improved default type parameters. No user-facing changes.

Copilot AI review requested due to automatic review settings November 18, 2025 23:34
@coderabbitai
Copy link

coderabbitai bot commented Nov 18, 2025

Walkthrough

This PR adds default generic type parameters across the API layer, enabling RestApiHandler, RPCApiHandler, RPCApiHandlerOptions, and ApiHandler to use SchemaDef as a default when the type parameter is omitted. These are compile-time type system modifications with no runtime behavior changes.

Changes

Cohort / File(s) Summary
Core API interface
packages/server/src/types.ts
ApiHandler interface now declares Schema extends SchemaDef = SchemaDef, providing a default generic type parameter.
REST API handler
packages/server/src/api/rest/index.ts
RestApiHandler class signature updated to include default generic: Schema extends SchemaDef = SchemaDef.
RPC API handlers
packages/server/src/api/rpc/index.ts
Both RPCApiHandlerOptions and RPCApiHandler now include default generic type parameter: Schema extends SchemaDef = SchemaDef.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Low complexity: Changes are purely type-level with no logic modifications
  • Homogeneous pattern: Identical default generic parameter syntax applied consistently across all affected declarations
  • Compile-time only: No runtime behavior alterations; changes only affect TypeScript type checking and inference

Poem

🐰 With whiskers twitching, I hop with glee,
Default types now flow so free!
SchemaDef defaults, clear and bright,
Your API calls will feel so right!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding default generic type parameters to API handler classes to simplify their typing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/simplify-api-handler-typing

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 710cb8b and 53935a2.

📒 Files selected for processing (3)
  • packages/server/src/api/rest/index.ts (1 hunks)
  • packages/server/src/api/rpc/index.ts (2 hunks)
  • packages/server/src/types.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/server/src/api/rpc/index.ts (2)
packages/schema/src/schema.ts (1)
  • SchemaDef (11-19)
packages/server/src/types.ts (1)
  • ApiHandler (67-82)
packages/server/src/api/rest/index.ts (2)
packages/schema/src/schema.ts (1)
  • SchemaDef (11-19)
packages/server/src/types.ts (1)
  • ApiHandler (67-82)
packages/server/src/types.ts (1)
packages/schema/src/schema.ts (1)
  • SchemaDef (11-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Upload results
  • GitHub Check: build-test (20.x, sqlite)
  • GitHub Check: build-test (20.x, postgresql)
  • GitHub Check: claude-review
🔇 Additional comments (5)
packages/server/src/types.ts (1)

67-67: LGTM! Default type parameter improves ergonomics.

The addition of the default type parameter = SchemaDef is a non-breaking change that allows ApiHandler to be used without explicitly providing the type parameter, improving developer experience while maintaining full type safety.

packages/server/src/api/rest/index.ts (2)

16-16: LGTM! Consistent default type parameter.

The default type parameter addition aligns with the same pattern applied to ApiHandler in packages/server/src/types.ts, maintaining consistency across the API layer.


119-119: LGTM! Class signature aligns with interface.

The default type parameter ensures RestApiHandler has the same ergonomic benefits as the ApiHandler interface it implements, allowing optional type parameter usage.

packages/server/src/api/rpc/index.ts (2)

14-14: LGTM! Consistent with REST API handler.

The default type parameter mirrors the pattern used in RestApiHandlerOptions, ensuring consistency between RPC and REST API handlers.


29-29: LGTM! Completes the uniform typing improvement.

This change completes the consistent application of default type parameters across all API handlers (RestApiHandler, RPCApiHandler, and ApiHandler), achieving the PR's objective of simplified generic typing.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Nov 18, 2025

Claude Code is working…

I'll analyze this and get back to you.

View job run

Copilot finished reviewing on behalf of ymc9 November 18, 2025 23:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR simplifies the generic typing of API handlers by adding default type parameters (= SchemaDef) to generic type constraints. This allows consumers to use these types without explicitly specifying the schema type parameter when the default is sufficient.

Key changes:

  • Added default type parameter to base ApiHandler interface
  • Added default type parameter to RPC handler class and options type
  • Added default type parameter to REST handler class

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/server/src/types.ts Added default type parameter to ApiHandler interface
packages/server/src/api/rpc/index.ts Added default type parameter to RPCApiHandler class and RPCApiHandlerOptions type
packages/server/src/api/rest/index.ts Added default type parameter to RestApiHandler class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ymc9 ymc9 merged commit 127393e into dev Nov 19, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants