I can\'t seem to properly pass the sequelize
object from the service.js
file to the index.js
sequelize variable.
Does anything loo
await new Sequelize(...)
in the code above expects that new Sequelize
returns a promise, while this is not so. There is authenticate method that does that.
It should be:
exports.init = async () => {
let sequelize = new Sequelize(...);
await sequelize.authenticate();
return sequelize;
};
Make sure promise rejections are always properly handled:
(async () => {
sequelize = await lambdaHelper.init();
contractModel = require('./models/Contract')(sequelize, Sequelize);
})().catch(console.error);