Skip to content

Commit

Permalink
Fixed showRoutes & inspectRoutes Hono parameter types
Browse files Browse the repository at this point in the history
  • Loading branch information
NuroDev committed Dec 4, 2023
1 parent 3d3f7c5 commit e9f0043
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/helper/dev/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Hono } from '../../hono'
import type { RouterRoute } from '../../types'
import type { Env, RouterRoute } from '../../types'

interface ShowRoutesOptions {
verbose?: boolean
Expand All @@ -17,7 +17,7 @@ const handlerName = (handler: Function) => {
return handler.name || (isMiddleware(handler) ? '[middleware]' : '[handler]')
}

export const inspectRoutes = (hono: Hono): RouteData[] => {
export const inspectRoutes = <TEnv extends Env>(hono: Hono<TEnv>): RouteData[] => {
return hono.routes.map(({ path, method, handler }: RouterRoute) => ({
path,
method,
Expand All @@ -26,7 +26,7 @@ export const inspectRoutes = (hono: Hono): RouteData[] => {
}))
}

export const showRoutes = (hono: Hono, opts?: ShowRoutesOptions) => {
export const showRoutes = <TEnv extends Env>(hono: Hono<TEnv>, opts?: ShowRoutesOptions) => {
const routeData: Record<string, RouteData[]> = {}
let maxMethodLength = 0
let maxPathLength = 0
Expand Down

0 comments on commit e9f0043

Please sign in to comment.