Skip to content

refactor: use zod-openapi for ensnode-api#1672

Merged
notrab merged 4 commits intomainfrom
zod-openapi-ensnode-api
Feb 26, 2026
Merged

refactor: use zod-openapi for ensnode-api#1672
notrab merged 4 commits intomainfrom
zod-openapi-ensnode-api

Conversation

@notrab
Copy link
Member

@notrab notrab commented Feb 24, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • Migrated ensnode-api routes (/config, /indexing-status) from describeRoute() (hono-openapi) to createRoute() (@hono/zod-openapi) pattern.
  • Renamed openapi-routes.ts to stub-routes.ts and createRoutesForSpec to createStubRoutesForSpec to clarify stub-only purpose.
  • Renamed openapi-documentation.ts to openapi-meta.ts and openapiDocumentation to openapiMeta.

Why

  • Continuing the migration of route definitions to @hono/zod-openapi for consistent OpenAPI spec generation across all endpoints.
  • Renaming files/exports to be explicit about their purpose (stub routes for spec generation, metadata for OpenAPI doc info).

Testing

  • No behaviour changes. Route definitions and handler logic are unchanged, only the registration mechanism was swapped.
  • Verified no other files import the old filenames or exports.

Notes for Reviewer (Optional)

  • ensnode-api.tsnow usescreateApp()(from@/lib/hono-factory) instead of factory.createApp(), matching the pattern used by the other migrated handlers (amirealtime-api.ts, resolution-api.ts`).
  • Remaining unmigrated handlers: name-tokens-api, registrar-actions-api, ensanalytics-api, ensanalytics-api-v1.

Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required)

@notrab notrab requested a review from a team as a code owner February 24, 2026 16:33
Copilot AI review requested due to automatic review settings February 24, 2026 16:33
@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

⚠️ No Changeset found

Latest commit: 20d1ba3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Contributor

vercel bot commented Feb 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Feb 24, 2026 5:37pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
ensnode.io Skipped Skipped Feb 24, 2026 5:37pm
ensrainbow.io Skipped Skipped Feb 24, 2026 5:37pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0367b9e and 20d1ba3.

📒 Files selected for processing (3)
  • apps/ensapi/src/handlers/ensnode-api.routes.ts
  • apps/ensapi/src/handlers/ensnode-api.ts
  • packages/ensnode-sdk/src/ensapi/api/indexing-status/serialize.ts

📝 Walkthrough

Walkthrough

Extracts two ENS API routes into a new routes metadata module, updates the main handler to wire those routes via app.openapi using a new createApp import, and includes the new route group in the stub route aggregator.

Changes

Cohort / File(s) Summary
New Route Configuration
apps/ensapi/src/handlers/ensnode-api.routes.ts
Adds basePath = "/api", getConfigRoute (GET /config) and getIndexingStatusRoute (GET /indexing-status) OpenAPI route definitions and exports routes array.
Handler wiring & imports
apps/ensapi/src/handlers/ensnode-api.ts
Replaces inline /config and /indexing-status handlers with app.openapi(...) delegations to the new route definitions; switches from factory.createApp() to createApp(); replaces indexing-status types/serializer imports to EnsApi-prefixed names.
Stub route aggregation
apps/ensapi/src/stub-routes.ts
Imports and includes ensnodeRoutes in routeGroups so the new routes are added to stub generation.
SDK serialization types
packages/ensnode-sdk/src/ensapi/api/indexing-status/serialize.ts
Adds precise TypeScript overloads for serializeEnsApiIndexingStatusResponse (Ok/Error/General) and updates imports/exports for EnsApi-specific response and serialized types; no runtime logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through code with a twitch and a grin,
Pulled routes from the clutter, tucked metadata in.
Now endpoints march tidy, each path in a row,
I nibble a carrot and watch the routes grow. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: migrating ensnode-api routes from hono-openapi to zod-openapi pattern.
Description check ✅ Passed The description covers all required sections (Summary, Why, Testing, Notes, Pre-Review Checklist) with sufficient detail about changes, rationale, testing approach, and reviewer context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch zod-openapi-ensnode-api

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.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 24, 2026

Greptile Summary

Migrated ensnode-api routes (/config, /indexing-status) from legacy hono-openapi (describeRoute()) to @hono/zod-openapi (createRoute()) pattern, matching the approach used in amirealtime-api and resolution-api.

Key changes:

  • Created new ensnode-api.routes.ts file with route definitions using createRoute()
  • Updated ensnode-api.ts to use app.openapi() for route registration and createApp() instead of factory.createApp()
  • Registered routes in stub-routes.ts for OpenAPI spec generation
  • Removed response schema definitions (consistent with other migrated APIs)
  • Handler logic remains completely unchanged

Confidence Score: 5/5

Important Files Changed

Filename Overview
apps/ensapi/src/handlers/ensnode-api.routes.ts New file defining route schemas for /config and /indexing-status using @hono/zod-openapi pattern
apps/ensapi/src/handlers/ensnode-api.ts Migrated from describeRoute() to app.openapi() pattern, removed old imports, switched to createApp()
apps/ensapi/src/stub-routes.ts Added ensnodeRoutes import and registration in stub routes array

Last reviewed commit: 8af0edc

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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

Migrates ensnode-api’s /config and /indexing-status endpoints to the @hono/zod-openapi (createRoute + app.openapi) route-definition pattern, and wires these route definitions into the stub OpenAPI route registration flow.

Changes:

  • Refactor ensnode-api handler to register endpoints via app.openapi(...) using new ensnode-api.routes.ts.
  • Add ensnode-api.routes.ts with createRoute(...) definitions for /config and /indexing-status.
  • Include ensnode-api.routes in createStubRoutesForSpec() route registration.

Reviewed changes

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

File Description
apps/ensapi/src/stub-routes.ts Adds ENSNode route definitions to stub OpenAPI route registration.
apps/ensapi/src/handlers/ensnode-api.ts Switches /config and /indexing-status to app.openapi registrations and uses createApp().
apps/ensapi/src/handlers/ensnode-api.routes.ts Introduces zod-openapi createRoute definitions for ENSNode meta endpoints.
Comments suppressed due to low confidence (1)

apps/ensapi/src/stub-routes.ts:19

  • createStubRoutesForSpec() builds OpenAPI paths from group.basePath + route.path, but this doesn’t match the real routing tree for nested apps (e.g., resolution-api is mounted at /api/resolve via ensnode-api.ts + index.ts, yet this will register /resolve/...). If this stub app is used for spec generation, the resulting OpenAPI paths will be incorrect. Consider encoding the mount hierarchy in this file (e.g., prefix resolution routes with /api), or switching the route groups to store an explicit full prefix per group instead of relying on each module’s basePath alone.
  const routeGroups = [amIRealtimeRoutes, ensnodeRoutes, resolutionRoutes];

  for (const group of routeGroups) {
    for (const route of group.routes) {
      const path = route.path === "/" ? group.basePath : `${group.basePath}${route.path}`;

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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/ensnode-api.routes.ts`:
- Around line 5-32: Both getConfigRoute and getIndexingStatusRoute are missing
response body schemas; add a content entry for "application/json" with a Zod
schema so `@hono/zod-openapi` can infer response types. Update the route objects
(getConfigRoute, getIndexingStatusRoute) to include responses like 200: {
description: "...", content: { "application/json": { schema: /* Zod schema
matching serializeENSApiPublicConfig() return type */ } } } and for the 503
response add a content schema for the error shape if applicable; use or derive
Zod schemas that match the existing serializer return shapes
(serializeENSApiPublicConfig and serializeIndexingStatusResponse) so the OpenAPI
output and handler c.json(...) payloads are type-checked.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2e772ab and 8af0edc.

📒 Files selected for processing (3)
  • apps/ensapi/src/handlers/ensnode-api.routes.ts
  • apps/ensapi/src/handlers/ensnode-api.ts
  • apps/ensapi/src/stub-routes.ts

@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io February 24, 2026 16:40 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io February 24, 2026 16:40 Inactive
@vercel vercel bot temporarily deployed to Preview – ensnode.io February 24, 2026 16:40 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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/ensnode-api.routes.ts`:
- Around line 28-49: The 503 response for getIndexingStatusRoute incorrectly
reuses makeSerializedEnsApiIndexingStatusResponseSchema() (a union of ok+error);
change the 503 response to use the SDK's error-only schema for this endpoint
instead so OpenAPI advertises only the error payload (replace the 503 content
schema with the SDK error-only schema for indexing status, e.g.
makeSerializedEnsApiIndexingStatusErrorResponseSchema or the equivalent
error-only factory provided by the SDK).

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8af0edc and 0367b9e.

📒 Files selected for processing (1)
  • apps/ensapi/src/handlers/ensnode-api.routes.ts

Copilot AI review requested due to automatic review settings February 24, 2026 17:02
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io February 24, 2026 17:02 Inactive
@vercel vercel bot temporarily deployed to Preview – ensnode.io February 24, 2026 17:02 Inactive
@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io February 24, 2026 17:02 Inactive
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

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.

Copy link
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@notrab Thanks for your updates. Shared a few suggestions. Please merge when ready.

@@ -0,0 +1,55 @@
import { createRoute } from "@hono/zod-openapi";

Copy link
Member

Choose a reason for hiding this comment

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

Let's rename this file to meta.routes.ts as all the routes here represent "meta" routes that return various metadata.

makeENSApiPublicConfigSchema,
makeIndexingStatusResponseSchema,
} from "@ensnode/ensnode-sdk/internal";

Copy link
Member

Choose a reason for hiding this comment

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

I note an inconsistency here.

For example: I see:

import ensnodeGraphQLApi from "./ensnode-graphql-api";
import nameTokensApi from "./name-tokens-api";
import registrarActionsApi from "./registrar-actions-api";
import resolutionApi from "./resolution-api";

... for many APIs. But why isn't this pattern followed for the "meta" API handlers for getting the config or indexing status (which are the "meta" APIs)?

Why are these API handlers defined directly in this file while no other APIs are directly implemented in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lightwalker-eth this was pre-existing inconsistency which is why I did not refactor it at this stage. I only refactored the meta handlers from hono-openapi (describeRoute / app.get) to zod-openapi (createRoute / app.openapi) and extracted the route definitions to ensnode-api.routes.ts.

@notrab notrab merged commit c6e7d5c into main Feb 26, 2026
16 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.

3 participants