refactor: use zod-openapi for name-tokens-api#1684
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
|
Warning Rate limit exceeded
⌛ 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 (1)
📝 WalkthroughWalkthroughA new Name Tokens API route module is introduced with Zod-based query schema validation, allowing clients to query tokens by domain ID or name. The existing handler is refactored to use the externalized route definition and adds early indexing status guards with updated error handling. The new routes are registered in the stub routes configuration. Changes
Sequence DiagramsequenceDiagram
actor Client
participant Route as Route Handler
participant Validator as Query Validator
participant IndexCheck as Indexing Status
participant SDK as SDK/Registry
participant Response as Response
Client->>Route: GET /api/name-tokens/?name=...
Route->>Validator: Validate query (domainId OR name)
Validator-->>Route: Query validated
Route->>IndexCheck: Check indexingStatus
alt IndexingStatus undefined
IndexCheck-->>Route: Error (503)
Route-->>Client: 503 Service Unavailable
else IndexingStatus is error
IndexCheck-->>Route: Error (503)
Route-->>Client: 503 Service Unavailable
else IndexingStatus OK
IndexCheck-->>Route: Status OK
Route->>SDK: Verify parent subregistry indexed
alt Not indexed or ENS_ROOT
SDK-->>Route: Not found
Route-->>Client: 404 Not Found
else Indexed
SDK->>SDK: Compute namehash & retrieve tokens
SDK-->>Route: Token data or empty
alt Tokens found
Route-->>Client: 200 OK with tokens
else No tokens
Route-->>Client: 404 Not Found
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Greptile SummarySuccessfully migrated
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: bdc9d7c |
There was a problem hiding this comment.
Pull request overview
This PR migrates the name-tokens-api from the legacy hono-openapi library (describeRoute/validate) to @hono/zod-openapi (createRoute/app.openapi), continuing the incremental migration started in PR #1672.
Changes:
- Created
name-tokens-api.routes.tswith route definitions and query schema extracted from the handler - Refactored
name-tokens-api.tsto usecreateApp()andapp.openapi()instead offactory.createApp()anddescribeRoute() - Registered the new routes in
stub-routes.tsfor OpenAPI spec generation
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
apps/ensapi/src/stub-routes.ts |
Imported and registered name-tokens-api routes for OpenAPI spec generation |
apps/ensapi/src/handlers/name-tokens-api.ts |
Migrated from describeRoute/validate to app.openapi; removed route definition code now in routes file; handler logic preserved |
apps/ensapi/src/handlers/name-tokens-api.routes.ts |
New file containing route definition, query schema, and basePath for OpenAPI spec generation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ensapi/src/handlers/name-tokens-api.ts`:
- Line 110: The error message string in name-tokens-api.ts used by the ENSNode
handler is missing a closing single quote after the template interpolation
'${name'; update the offending literal (the message starting "This ENSNode
instance has not been configured to index tokens for the requested name:
'${name") to include the closing single quote so it becomes '${name}' (adjusting
the surrounding quotes/escaping as needed) so the string is syntactically valid
where it’s used in the ENSNode-related error/throw.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
apps/ensapi/src/handlers/name-tokens-api.routes.tsapps/ensapi/src/handlers/name-tokens-api.tsapps/ensapi/src/stub-routes.ts
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lightwalker-eth
left a comment
There was a problem hiding this comment.
@notrab Looks good, thanks 👍
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
name-tokens-apifromhono-openapi(describeRoute/validate) to@hono/zod-openapi(createRoute/app.openapi), following the established pattern from prior migrations.name-tokens-api.routes.tsextracting the route definition and query schema; updated the handler to usecreateApp()andapp.openapi().stub-routes.tsfor OpenAPI spec generation.Why
@hono/zod-openapiso all REST routes can generate an OpenAPI spec at runtime viastub-routes.ts.amirealtime-api,resolution-api, andensnode-api.Testing
typecheckpasseslintpassesNotes for Reviewer (Optional)
configimport andindexedSubregistriescomputation remain in the handler file (not the routes file), since they depend on runtime config/env vars that the stub routes must avoid importing.After this,
ensanalytics-api(2 routes),ensanalytics-api-v1(3 routes) remain to be migrated.Pre-Review Checklist (Blocking)