const Agenda = require("agenda");
const agenda = new Agenda({ db: { address: "mongodb://db:27017/agendaDb" } });
const {Agent} = require('./agent');
const agent = new Agent();

// Define a job
agenda.define('followSale', async (job, done) => {
    const { saleId } = job.attrs.data;
    agent.followSale(saleId)
        .then(data => {;
            done();
        })
  });

  agenda.define('prepareSale', async (job, done) => {
    const { saleId } = job.attrs.data;
    agent.prepareSale(saleId)
        .then(data => {;
            done();
        })
  });

module.exports = agenda;