@cocoframe/router
v0.0.3
Published
Small method-aware static and parameterized router for CocoFrame.
Maintainers
Readme
@cocoframe/router
Small method-aware router for static, parameterized, and catch-all patterns.
Router<Handler>registers, matches, and reports route manifests.normalizePath(pathname)applies one path convention.HttpMethodandRouteMatchdescribe the typed boundary.
const router = new Router<Handler>();
router.add("GET", "/posts/:slug", handler);
const match = router.match("GET", "/posts/hello");Static routes use direct map lookup. Dynamic patterns compile once during
registration and sort by specificity; never compile regular expressions per
request. Verify with tests/router.test.ts and route discovery tests.
