In ./app_api/routes/index.js
var router = express.Router()
var ctrlLocations = require('../controllers/locations')
router.post( '/', ctrlLocations.helloCreate );
module.exports = router
In app.js
var routesApi = require('./app_api/routes/index');
app.use('/', routesApi)
I am guessing that variable routesApi
contains a reference to the variable router
of index.js
.
What does require()
return which is used in app.use()
?
How does app.use('/', routesApi)
know which function to call from index.js
. There can be many functions there? How does this work internally?