D
Deno

help

How do I have a subrouter in Oak?

Aalexp9510/17/2023
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);
Aakumaruь10/17/2023
Hi there. I've used Express before, But first time seeing something like subrouter, can you provide a link, please?
Ffro.profesional10/17/2023
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 🐿️ 🦕
MMongalorian10/17/2023
You should be able to nest routers like this:
router.use(
'/subroute',
subRouter.routes(),
subRouter.allowedMethods(),
)
router.use(
'/subroute',
subRouter.routes(),
subRouter.allowedMethods(),
)
Aalexp9510/27/2023
it worked, thank you!

Looking for more? Join the community!