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 in Node-js by Neha
• 8,920 points
15 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
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 in Node-js by Neha
• 8,920 points
220 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 in Node-js by Neha
• 8,920 points
17 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 in Node-js by Neha
• 8,920 points
446 views
0 votes
1 answer

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

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

answered Jun 17 in Node-js by Neha
• 8,920 points
37 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 in Node-js by Neha
• 8,920 points
30 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,043 views
0 votes
1 answer
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,080 points
2,104 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP