import { launchWeb } from './web.js'; import { EventEmitter } from 'events'; import { loadDatabase } from './utils/database.js'; import dotenv from 'dotenv'; dotenv.config(); loadDatabase(); const submitEvent = new EventEmitter(); await launchWeb(submitEvent); submitEvent.on("contacts/call", async (call) => { let vote; if (call.vote) { console.log(`${call.phone} va voter`); vote = 1; } else { console.log(`${call.phone} ne va pas voter`); vote = 0; } await global.database.contacts.update( { vote: vote, called: 1 }, { where: { phone: call.phone } }, ); }); submitEvent.on("contacts/add", (request) => { console.log(request); }); global.events = { submitEvent: submitEvent, }