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
384 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,222 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,534 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
312 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
7,031 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
777 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
322 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,732 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,259 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,869 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