'use strict'; const http = require('http'); const server = require('./server'); const { port } = require('./config').server; const { createWhatsApp } = require('./core'); async function bootstrap() { // const whatsApp1 = await createWhatsApp('channel_001', '8618777396951'); // console.info(whatsApp1); // const whatsApp2 = await createWhatsApp('channel_002', '8613557032060'); // console.info(whatsApp2); /** * Add external services init as async operations (db, redis, etc...) * e.g. * await sequelize.authenticate() */ return http.createServer(server.callback()).listen(port, '0.0.0.0'); } bootstrap() .then(server => { console.log(`🚀 Server listening on port ${server.address().port}!`); }) .catch(err => { setImmediate(() => { console.error('Unable to run the server because of the following error:'); console.error(err); process.exit(); }); });