nitty-router
v0.0.4
Published
Simple router for creating nested routes
Downloads
13
Maintainers
Readme
nitty-router
Nitty Router Nesting based without base, powered by itty-router.
For documentation please refer https://itty.dev/
Use
Use similar to express js middleware function use
Example
const grandchild = Router()
.get("/", (req) => req)
.all("*", () => "not found grandchild");
const child = Router()
.get("/", (req) => req.params.bar)
.use("grandchild/:name", grandchild)
.all("*", () => "not found child");
const parent = Router()
.get("/", () => "parent")
.use("child/:bar", child)
.all("*", () => "not found parent");
parent
.fetch({
url: "http://localhost/child/kitten/grandchild/mitten",
method: "GET",
})
.then(console.log)
.catch(console.error);