I am following this tutorial. I am changing existing AWS Lambda based app to NodeJS Express app.
server.js imports the module and executes it passing the Express app as an argument:
require('./handlers/getStatus')(app);
The module is trivial, it exports a function with single argument
exports = app => {
app.get('/v1/status', (req, res) => {
console.log("handler starts");
const response = {
api: '1.0',
status: 'OK'
};
return res.send(response);
});
};
When I run this app with Node v13.11.0, there is an error:
node server.js
C:\dev\mezinamiridici\infrastructure\src\server.js:5
require('./handlers/getStatus')(app); ^
TypeError: require(...) is not a function
at Object.<anonymous> (C:\dev\mezinamiridici\infrastructure\src\server.js:5:32)
at Module._compile (internal/modules/cjs/loader.js:1147:30)
Why? Thank you