Socket
Socket
Sign inDemoInstall

@fastify/schedule

Package Overview
Dependencies
69
Maintainers
19
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @fastify/schedule

Fastify plugin for scheduling periodic jobs


Version published
Weekly downloads
4.4K
decreased by-7.09%
Maintainers
19
Install size
44.4 kB
Created
Weekly downloads
 

Readme

Source

@fastify/schedule

CI NPM version NPM downloads js-standard-style

Fastify plugin for scheduling periodic jobs. Provides an instance of toad-scheduler on fastify instance.
Jobs are stopped automatically when the fastify instance is stopped.

Getting started

First install the package:

npm i @fastify/schedule toad-scheduler

Next, set up the plugin:

const fastify = require('fastify')();
const { fastifySchedulePlugin } = require('@fastify/schedule');
const { SimpleIntervalJob, AsyncTask } = require('toad-scheduler');

const task = new AsyncTask(
    'simple task',
    () => { return db.pollForSomeData().then((result) => { /* continue the promise chain */ }) },
    (err) => { /* handle errors here */ }
)
const job = new SimpleIntervalJob({ seconds: 20, }, task)

fastify.register(fastifySchedulePlugin);

// `fastify.scheduler` becomes available after initialization.
// Therefore, you need to call `ready` method.
fastify.ready().then(() => {
    fastify.scheduler.addSimpleIntervalJob(job)
})

For more detailed instructions, see the documentation of toad-scheduler.

Keywords

FAQs

Last updated on 15 Jun 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc