feat: migrate resolution api to Zod OpenAPI#1662
Conversation
…to use `createRoute()` + `app.openapi()`. Add `pnpm generate:openapi` script for env-free OpenAPI 3.1 spec generation.
|
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 (3)
✨ 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 SummaryThis PR successfully migrates the resolution API's three endpoints from the legacy Key changes:
No behavioral changes - all handler logic, middleware, validation schemas, and the critical Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 0d515e2 |
There was a problem hiding this comment.
Pull request overview
This PR aims to migrate the resolution API's three endpoints (/records/:name, /primary-name/:address/:chainId, /primary-names/:address) from the legacy hono-openapi pattern to @hono/zod-openapi, following the pattern established in PR #1661. The migration extracts route metadata into a separate routes file to enable environment-free OpenAPI spec generation at build time.
Changes:
- Converted handler registration from
app.get+describeRoute+validatetoapp.openapiwith route definitions - Replaced
factory.createApp()withcreateApp()to use OpenAPIHono - Extracted route metadata to
resolution-api.routes.ts(missing from PR)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/ensapi/src/handlers/resolution-api.ts | Migrated three endpoint handlers to use app.openapi() pattern and import route definitions from missing routes file |
| apps/ensapi/src/openapi-routes.ts | Added import and registration for resolution routes module |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@greptile-apps re-review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| import { params } from "@/lib/handlers/params.schema"; | ||
|
|
||
| export const basePath = "/resolve"; |
There was a problem hiding this comment.
basePath is used by createStubRoutesForSpec() to prefix each route’s path for OpenAPI generation. Since the resolution handler is mounted under /api (see index.ts -> app.route("/api", ensNodeApi) and ensnode-api.ts -> app.route("/resolve", resolutionApi)), the externally reachable paths are /api/resolve/.... As written, the generated spec paths will be missing the /api prefix. Consider changing basePath to /api/resolve (or otherwise incorporating the parent mount path into spec generation).
| export const basePath = "/resolve"; | |
| export const basePath = "/api/resolve"; |
| @@ -10,7 +11,7 @@ import * as amIRealtimeRoutes from "./handlers/amirealtime-api.routes"; | |||
| export function createStubRoutesForSpec() { | |||
| const app = new OpenAPIHono(); | |||
|
|
|||
| const routeGroups = [amIRealtimeRoutes]; | |||
| const routeGroups = [amIRealtimeRoutes, resolutionRoutes]; | |||
|
|
|||
There was a problem hiding this comment.
The PR description mentions registering the new route metadata in openapi-routes.ts, but this change registers resolution-api.routes in stub-routes.ts instead. To avoid confusion for reviewers/follow-ups, update the PR description (or ensure the intended spec registration file exists and is used).
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
/records/:name,/primary-name/:address/:chainId,/primary-names/:address) fromhono-openapi(describeRoute+validate) to@hono/zod-openapi(createRoute+app.openapi).resolution-api.routes.tsfile and registered it inopenapi-routes.tsfor env-free spec generation.Why
Continues the incremental migration started in #1661 to enable OpenAPI spec generation at build time without starting the server or requiring env vars.
Testing
tsc --noEmit)biome check)Notes for Reviewer (Optional)
makeIsRealtimeMiddleware,canAccelerateMiddleware), and all Zod schemas are unchanged. This is a purely structural conversion./records/{name}query schema preserves the existing.transform()that callsparams.selection.parse()internally.validate.tsandhono-openapiare intentionally left in place. Other unconverted routes still depend on them.Pre-Review Checklist (Blocking)