NodeJS express - routing

0 votes
I´ve setup a little NodeJS API with 'expressjs'. In my code I have some similar code blocks looking like this:

app.get('/api/my/path', (req, res) => {
  doSomethingUseful();
});
All thoses requests do something different, so the function being called is always different too.

I´m asking myself if this is good practice for writing code in NodeJS or not. If there is a better / cleaner way of writing all those paths I would appreciate if you could tell me how or at least giving me a place to look for it.

EDIT 1: To be clear: I ask if it´s a good idea to write a lot of 'app.get(...)' into one source code file or if there is a better way?
Aug 19, 2022 in Node-js by Neha
• 9,060 points
364 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Node-js

0 votes
1 answer

What is the role of Nodejs and Express in a MERN stack web application when GraphQL is also used?

Node.js is a JavaScript runtime environment, which ...READ MORE

answered May 27, 2022 in Node-js by Neha
• 9,060 points
2,174 views
0 votes
1 answer

NodeJS express get request is not working on mobile

For your API call, try to add ...READ MORE

answered Jun 7, 2022 in Node-js by Neha
• 9,060 points
1,487 views
0 votes
1 answer

NodeJS express get request is not working on mobile

For your API call, try to add ...READ MORE

answered Jun 9, 2022 in Node-js by Neha
• 9,060 points
292 views
0 votes
1 answer

Download a file from NodeJS Server using Express

Because the file's name is just 'download' ...READ MORE

answered Jun 13, 2022 in Node-js by Neha
• 9,060 points
6,946 views
0 votes
1 answer

NodeJS / Express: what is "app.use"?

The app object is instantiated on creation ...READ MORE

answered Jun 17, 2022 in Node-js by Neha
• 9,060 points
751 views
0 votes
0 answers

Nodejs + Express vs Django: Choosing the best suitable backend component for given requirements

I'm trying to build a software architecture ...READ MORE

Aug 11, 2022 in Node-js by Neha
• 9,060 points
294 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,708 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,241 views
0 votes
1 answer

Unable to start express server on AWS instance

It's not your code — you can't connect ...READ MORE

answered Oct 1, 2018 in AWS by Priyaj
• 58,090 points
2,832 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP