feat: auto-discover API endpoints for API Reference page#664
Open
mmcintosh wants to merge 1 commit intoSonicJs-Org:mainfrom
Open
feat: auto-discover API endpoints for API Reference page#664mmcintosh wants to merge 1 commit intoSonicJs-Org:mainfrom
mmcintosh wants to merge 1 commit intoSonicJs-Org:mainfrom
Conversation
Replace the static hardcoded array of 27 endpoints with runtime auto-discovery using Hono's inspectRoutes(). The API Reference page now automatically shows all registered API routes without manual updates when new routes are added. - Add route-metadata service with inspectRoutes() integration - Whitelist-based filtering to show only API endpoints - Metadata registry for descriptions, auth status, and categories - Dynamic category dropdown built from actual discovered routes - Visual badges for auth status (Auth/Public/Unknown) - Auto-discovered badge for routes without metadata - Stats bar with Total, Public, Protected, Categories, Undocumented counts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace the static hardcoded array of 27 endpoints on the API Reference page (
/admin/api-reference) with runtime auto-discovery using Hono'sinspectRoutes(). The page now automatically shows every registered API route without requiring manual updates when new routes are added.The old approach required developers to manually add each new endpoint to a static array in
admin-api-reference.ts— which clearly drifted, as 5 entire categories were missing. This PR makes the page self-healing: any route registered inapp.tsis automatically discovered and displayed.Changes
New service:
packages/core/src/services/route-metadata.tsinspectRoutes()fromhono/devto discover all registered routes at runtimepackages/core/src/app.ts(+4 lines)setAppInstancefrom route-metadata servicesetAppInstance(app)after all routes are registered, before the 404 handlerpackages/core/src/services/index.ts(+9 lines)buildRouteList,setAppInstance,getAppInstance,CATEGORY_INFO,RouteMetadata)packages/core/src/routes/admin-api-reference.ts(rewritten, 279 → ~80 lines)apiEndpointsarraybuildRouteList(getAppInstance())for live discoverypackages/core/src/templates/pages/admin-api-reference.template.ts(updated)CATEGORY_INFOconstantTesting
Manual Verification
npm run buildinpackages/core)Unit Tests
E2E Tests
Key Property
The number of endpoints shown on the page will vary by deployment —
inspectRoutes()only discovers what's actually registered. On upstream (which may have fewer plugins), the page simply shows fewer endpoints. Extra metadata entries for routes that don't exist are harmless unused lookups.Screenshots/Videos
Checklist