Socket
Socket
Sign inDemoInstall

agenda

Package Overview
Dependencies
Maintainers
8
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agenda

Light weight job scheduler for Node.js


Version published
Weekly downloads
122K
increased by5.17%
Maintainers
8
Weekly downloads
 
Created

What is agenda?

Agenda is a lightweight job scheduling library for Node.js. It allows you to define, schedule, and manage jobs with ease. It is built on top of MongoDB and provides a simple yet powerful API for job scheduling and management.

What are agenda's main functionalities?

Define Jobs

This feature allows you to define a job with a specific name and the logic that should be executed when the job runs. In this example, a job named 'send email' is defined, which logs the email details to the console.

const Agenda = require('agenda');
const agenda = new Agenda({ db: { address: 'mongodb://localhost/agenda' } });

agenda.define('send email', async job => {
  const { to, subject, body } = job.attrs.data;
  // logic to send email
  console.log(`Sending email to ${to} with subject ${subject}`);
});

Schedule Jobs

This feature allows you to schedule a job to run at a specific time. In this example, the 'send email' job is scheduled to run in 2 minutes with the provided data.

agenda.on('ready', async () => {
  await agenda.start();
  await agenda.schedule('in 2 minutes', 'send email', { to: 'example@example.com', subject: 'Hello', body: 'Hello World' });
});

Recurring Jobs

This feature allows you to schedule recurring jobs. In this example, the 'send email' job is scheduled to run every hour with the provided data.

agenda.on('ready', async () => {
  await agenda.start();
  await agenda.every('1 hour', 'send email', { to: 'example@example.com', subject: 'Hourly Update', body: 'This is your hourly update.' });
});

Job Cancellation

This feature allows you to cancel jobs. In this example, all jobs with the name 'send email' are cancelled.

agenda.on('ready', async () => {
  await agenda.start();
  await agenda.cancel({ name: 'send email' });
});

Other packages similar to agenda

Keywords

FAQs

Package last updated on 09 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc