简体   繁体   中英

what is “app.router” express.js

in the default app.js generated by express.js, there is a following line:

...
app.use(app.router);
... 

I am confused by this line of code, because 1) I couldn't find app has a property with the name "router" on express api doc . 2) "app.router" is not mentioned/defined in the code.

There is a one property called "app.routes". it is not the same thing, right?

Please help me explain what is app.router and where it comes from. Thank you!

app.router is the routing middleware of Express. In other words, it's the middleware that is used to process incoming requests and match them to any routes that you may have set up.

Even though the default app adds it, it's not required because Express will automatically add the routing middleware when you first declare a route.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM