Z User
phase7: MCP stdio smoke test (handshake + tools/list + get_roots 6:74) — 4/4 tests PASS
54a6341 Download node_modules/hono/dist/helper/dev/index.js from bravesigma/quran-md-plugin: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/node_modules/hono/dist/helper/dev/index.js
- Command line
-
hf download hf://datasets/bravesigma/quran-md-plugin/node_modules/hono/dist/helper/dev/index.js
-
curl -L -o index.js https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/node_modules/hono/dist/helper/dev/index.js
1.71 kB
| import { getColorEnabled } from "../../utils/color.js"; | |
| import { findTargetHandler, isMiddleware } from "../../utils/handler.js"; | |
| //#region src/helper/dev/index.ts | |
| const handlerName = (handler) => { | |
| return handler.name || (isMiddleware(handler) ? "[middleware]" : "[handler]"); | |
| }; | |
| const inspectRoutes = (hono) => { | |
| return hono.routes.map(({ path, method, handler }) => { | |
| const targetHandler = findTargetHandler(handler); | |
| return { | |
| path, | |
| method, | |
| name: handlerName(targetHandler), | |
| isMiddleware: isMiddleware(targetHandler) | |
| }; | |
| }); | |
| }; | |
| const showRoutes = (hono, opts) => { | |
| const colorEnabled = opts?.colorize ?? getColorEnabled(); | |
| const routeData = {}; | |
| let maxMethodLength = 0; | |
| let maxPathLength = 0; | |
| inspectRoutes(hono).filter(({ isMiddleware }) => opts?.verbose || !isMiddleware).map((route) => { | |
| const key = `${route.method}-${route.path}`; | |
| (routeData[key] ||= []).push(route); | |
| if (routeData[key].length > 1) return; | |
| maxMethodLength = Math.max(maxMethodLength, route.method.length); | |
| maxPathLength = Math.max(maxPathLength, route.path.length); | |
| return { | |
| method: route.method, | |
| path: route.path, | |
| routes: routeData[key] | |
| }; | |
| }).forEach((data) => { | |
| if (!data) return; | |
| const { method, path, routes } = data; | |
| const methodStr = colorEnabled ? `\x1b[32m${method}\x1b[0m` : method; | |
| console.log(`${methodStr} ${" ".repeat(maxMethodLength - method.length)} ${path}`); | |
| if (!opts?.verbose) return; | |
| routes.forEach(({ name }) => { | |
| console.log(`${" ".repeat(maxMethodLength + 3)} ${name}`); | |
| }); | |
| }); | |
| }; | |
| const getRouterName = (app) => { | |
| app.router.match("GET", "/"); | |
| return app.router.name; | |
| }; | |
| //#endregion | |
| export { getRouterName, inspectRoutes, showRoutes }; | |