DEV Community

loading...

Discussion on: NodeJS: How To Add Routes To Our Express Server

Collapse
thecodingalpaca profile image
Carlos Trapet

I was thinking about this the other day and I'm looking for input from other developers, and I can't find an answer I like;

How would you handle routing if your service had a large amount of exposed routes? (By "large" I mean between 50 to 100)

Collapse
hilleer profile image
Daniel Hillmann

I would suggest creating multiple routers with express.Router() each handling it's own route, e.g. /api and /app.
If you have multiple depth levels you could create additional routers and attach to your express application.

If it has interest and you want further explanation I can try to write a post about it :-)

Collapse
thecodingalpaca profile image
Carlos Trapet • Edited

Yeah that sounds like the cleanest solution, probably. And build each route/app/section in its own containerised module.

Yeah if you write a post let me know and I'll happily read it! :)
Cheers man!

EDIT: ah, you live in Copenhagen <3 my favourite city in the world. Hope to some day move there, sooner, rather than later!

Thread Thread
hilleer profile image
Daniel Hillmann • Edited

Exactly!

Sure, will do :-)

Yes, it indeed is a decent city - and there seem to be a high demand for developers of many different flavours. Just saying 😉

Thread Thread
thecodingalpaca profile image
Carlos Trapet

Yeah, I did some browsing not too long ago and there seem to be some Node/React/JS roles advertised, although not a great deal.
And the entry barrier seems really high, so I assume the demand for devs isn't as high as here in London.

Thread Thread
hilleer profile image
Daniel Hillmann

I see.

I can't compare between the two, as I have no knowledge about the demand in London (or other places in general than Copenhagen). I can suggest you to keep and eye on thehub.dk/ or signup for their weekly job emails - there does come interesting Node/React/JS posts from time to time.

Thread Thread
thecodingalpaca profile image
Carlos Trapet

Nice one, that looks exactly like what I was looking for!
Cheers!

Forem Open with the Forem app