Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda