Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
node js express js request response circle

I am curious and really willing to learn and understand the whole concept behind the request and response circle of all backend

my question is I have a node js express framework

app is started

app.use('/api',router)


require('./routers/user')(router)
require('./routers/uretim')(router)
require('./routers/durus')(router)
require('./routers/rapor')(router)```

all my functions are called and executed and waiting for a request

since the order of this app is first use app.use('/api',router)

then the router is called at this particular point router function has nothing attached to it,

so does it mean as we started our application we have created the routes with the executed functions below the app.use

main question

user enter ..../api

our back end was hit

what is the first process, or function that happens within our backend?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

So the USE is used to load middleware, what you have is to use the router middleware on the /get url..

A better example of what is happening here is to define some action middleware on that url :

app.use("/api", (req, res, next) => {
    // For example, a GET request to `/api` will print "GET /api"
    console.log(`${req.method} ${req.url}`);
  
    next();
  });

When you start your server, if you hit your /api url, it will log the request info in the console and continue.

However the other URL's will not.. So you can tailor specific middleware for certain endpoints.

As for your routing itself, you will need to define the routes and their controller logic. Something like :

// HTTP GET Request Definition
app.get('/api',(req, res) => {
    res.send("Hey, you hit API");
} );

This will happen after the middleware has been actioned.

Express

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!