|
1 | 1 | // deno-lint-ignore-file
|
2 |
| -import { NextFunction, Router, Handler, Middleware, UseMethodParams } from 'https://esm.sh/@tinyhttp/router' |
3 |
| -export type { NextFunction, Router, Handler, Middleware, UseMethodParams } |
| 2 | +import { Router, serve, Server } from './deps.ts' |
| 3 | +import { NextFunction, Handler, Middleware, UseMethodParams } from './types.ts' |
4 | 4 | import { onErrorHandler, ErrorHandler } from './onError.ts'
|
5 | 5 | // import { setImmediate } from 'https://deno.land/std@0.88.0/node/timers.ts'
|
6 | 6 | import rg from 'https://esm.sh/regexparam'
|
7 |
| -import { Request, getRouteFromApp } from './request.ts' |
8 |
| -import { Response } from './response.ts' |
| 7 | +import type { Request } from './request.ts' |
| 8 | +import type { Response } from './response.ts' |
9 | 9 | import { getURLParams, getPathname } from './utils/parseUrl.ts'
|
10 | 10 | import { extendMiddleware } from './extend.ts'
|
11 |
| -import { serve, Server } from 'https://deno.land/std/http/server.ts' |
12 | 11 | import * as path from 'https://deno.land/std/path/mod.ts'
|
13 | 12 |
|
14 | 13 | const lead = (x: string) => (x.charCodeAt(0) === 47 ? x : '/' + x)
|
@@ -81,6 +80,9 @@ export type TemplateEngineOptions<O = any> = Partial<{
|
81 | 80 | _locals: Record<string, any>
|
82 | 81 | }>
|
83 | 82 |
|
| 83 | +export const getRouteFromApp = ({ middleware }: App, h: Handler) => |
| 84 | + middleware.find(({ handler }) => typeof handler === 'function' && handler.name === h.name) |
| 85 | + |
84 | 86 | /**
|
85 | 87 | * `App` class - the starting point of tinyhttp app.
|
86 | 88 | *
|
|
0 commit comments