Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
client.subscribe("invoiceCreator", async function({ task, taskService }) {
// Put your business logic
// complete the task
const date = new Date();
const invoice = await new File({ localPath: "./assets/invoice.txt" }).load();
const minute = date.getMinutes();
const variables = new Variables().setAll({ invoice, date });
// check if minute is even
if (minute % 2 === 0) {
// for even minutes, store variables in the process scope
await taskService.complete(task, variables);
} else {
// for odd minutes, store variables in the task local scope
await taskService.complete(task, null, variables);
}
});