Buckets:
| // src/helper/dev/index.ts | |
| import { getColorEnabled } from "../../utils/color.js"; | |
| import { findTargetHandler, isMiddleware } from "../../utils/handler.js"; | |
| var handlerName = (handler) => { | |
| return handler.name || (isMiddleware(handler) ? "[middleware]" : "[handler]"); | |
| }; | |
| var inspectRoutes = (hono) => { | |
| return hono.routes.map(({ path, method, handler }) => { | |
| const targetHandler = findTargetHandler(handler); | |
| return { | |
| path, | |
| method, | |
| name: handlerName(targetHandler), | |
| isMiddleware: isMiddleware(targetHandler) | |
| }; | |
| }); | |
| }; | |
| var showRoutes = (hono, opts) => { | |
| const colorEnabled = opts?.colorize ?? getColorEnabled(); | |
| const routeData = {}; | |
| let maxMethodLength = 0; | |
| let maxPathLength = 0; | |
| inspectRoutes(hono).filter(({ isMiddleware: isMiddleware2 }) => opts?.verbose || !isMiddleware2).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}`); | |
| }); | |
| }); | |
| }; | |
| var getRouterName = (app) => { | |
| app.router.match("GET", "/"); | |
| return app.router.name; | |
| }; | |
| export { | |
| getRouterName, | |
| inspectRoutes, | |
| showRoutes | |
| }; | |
Xet Storage Details
- Size:
- 1.79 kB
- Xet hash:
- 17eca9ed3d96e6bbeb0ab6ab1659b8c26a602d401c702325514e8c99d41d925f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.