title: Node.js access to a method from another module
body: <p>I would to access to a method from another module calling that method inside a route.
  with this notation of module.exports does't work beacause in my console I get an error like getProducts is not a function</p>
  
  <pre><code>const express = require('express');
  const router = express.Router();
  const path = require('path');
  const productsController = require('../controller/productsController')
  
  const productModel = require('../models/productModel');
  
  // send html file
  router.get('/', function (req, res) {
      res.sendFile(path.join(__dirname, '../public/esercitazione-AJAX.html'));
    });
    //to  /getProducts call a method from productsController
    router.get('/getProducts', function (req, res){
  
    productsController.productsController()
  });
  
  module.exports = router;
  </code></pre>
  
  <p>this is my module </p>
  
  <pre><code>//productsController.js
  const productModel = require('../models/productModel');
  
  var productsController = function() {
    console.log('productsController')
  
    var getProducts = function(req,res,callback) {
      var callback = function(result) {
  
        res.send(result);
      }
      productModel.getProducts(req, res, callback);
    }
  }
  
  module.exports = new  productsController();
  </code></pre>