I am using Express 4 server for Node.js
There is a router baked into Express like so:
in app.js
var router =
Express().get
does the same as Express.Router().get
. The difference is that router is better practice because it allows us to manage api endpoints as a middleware.
https://expressjs.com/en/api.html#router
The problem with Express and JS frameworks like it is that the documentation doesn't explain why the shift from using the Express main "app" object. My guess is that we should separate concerns from the logic of routes from the main application management itself (ie. configuration, template, database connection, etc.)