mirror of
https://github.com/honojs/hono.git
synced 2024-11-25 13:19:30 +01:00
677b572fd5
* wip * Use RegExp instead of URLPattern. (#1039) * Use RegExp instead of URLPattern. * refactor(url-pattern-router): tidy up. * refactor(url-pattern-router): Tweaks type for mangling. * refactor: Rename URLPatternRouter to PatternRouter. * chore: denoify. --------- Co-authored-by: Taku Amano <taku@taaas.jp>
18 lines
404 B
TypeScript
18 lines
404 B
TypeScript
import TrekRouter from 'npm:trek-router'
|
|
import type { RouterInterface } from './tool.mts'
|
|
import { routes, handler } from './tool.mts'
|
|
|
|
const name = 'trek-router'
|
|
|
|
const router = new TrekRouter()
|
|
for (const route of routes) {
|
|
router.add(route.method, route.path, handler())
|
|
}
|
|
|
|
export const trekRouter: RouterInterface = {
|
|
name,
|
|
match: (route) => {
|
|
router.find(route.method, route.path)
|
|
},
|
|
}
|