alexp95
alexp9514mo ago

How do I have a subrouter in Oak?

I want to use a subrouter in oak to handle part of the routing, how would I do that in Oak? here is an example in Express.js
app.use("/path/to/subrouter", subrouter);
app.use("/path/to/subrouter", subrouter);
4 Replies
akumaruь
akumaruь14mo ago
Hi there. I've used Express before, But first time seeing something like subrouter, can you provide a link, please?
fro.profesional
fro.profesional14mo ago
GitHub
GitHub - oakserver/oak: A middleware framework for handling HTTP wi...
A middleware framework for handling HTTP with Deno 🐿️ 🦕 - GitHub - oakserver/oak: A middleware framework for handling HTTP with Deno 🐿️ 🦕
Mongalorian
Mongalorian14mo ago
You should be able to nest routers like this:
router.use(
'/subroute',
subRouter.routes(),
subRouter.allowedMethods(),
)
router.use(
'/subroute',
subRouter.routes(),
subRouter.allowedMethods(),
)
alexp95
alexp95OP14mo ago
it worked, thank you!