Usually, my router is where I delegate chunks of the API off to appropriate sub-routers to then get more detailed with how things get done :)
I also usually version my REST APIs (like v1Router).
importexpressfrom'express'import{userRouter}from'../../../../modules/users/infra/http/routes';import{memberRouter,commentRouter}from'../../../../modules/forum/infra/http/routes';import{postRouter}from'../../../../modules/forum/infra/http/routes/post';constv1Router=express.Router();v1Router.get('/',(req,res)=>{returnres.json({message:"Yo! we're up"});})v1Router.use('/users',userRouter);v1Router.use('/members',memberRouter);v1Router.use('/posts',postRouter);v1Router.use('/comments',commentRouter);export{v1Router}// or { router }, like the rest of the code.
Scary, secret things... Just kidding.
Usually, my router is where I delegate chunks of the API off to appropriate sub-routers to then get more detailed with how things get done :)
I also usually version my REST APIs (like
v1Router
).You can see this code in the project it's from here, btw.
Appreciated ❤️