When I call awsServerlessExpress.createServer with my exported express app as the first parameter I get the error
"listener" argument must be a function
at _addListener events.js:216
at Server.addListener events.js:270
at new Server _http_server.js:231
at Object.exports.createServer http.js:44
at Object.exports.createServer ./node_modules/aws-serverless-express/index.js:134
Listener appears to be the first parameter in the createServer function. I don't understand how listener could be a function if it's my express app.
My full code reads:
const awsServerlessExpress = require('aws-serverless-express');
const app = require('./dist/server');
const server = awsServerlessExpress.createServer(app);
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context);
Any ideas?
Ah... classic ES6 export with an ES5 import.
Fixed with const app = require('./dist/server').default;
Most helpful comment
Ah... classic ES6 export with an ES5 import.
Fixed with
const app = require('./dist/server').default;