Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dexare/cron

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dexare/cron

A Dexare module that manages cron jobs

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

A Dexare module for managing crons.

npm install @dexare/cron
const { DexareClient } = require('dexare');
const CronModule = require('@dexare/cron');

const config = {
  // All props in this config are optional, defaults are shown unless told otherwise
  cron: {
    // The folder path to load upon loading the module, defaults to none
    // When registering crons in a folder, they must end with `.cron.js`
    loadFolder: './src/crons'
  }
}

const client = new DexareClient(config);
client.loadModules(CronModule);

const cron = client.modules.get('cron');
// You can choose to register crons from folders
cron.registerFromFolder('./src/crons');
// Or register a cron directly
cron.register({
  name: 'example-cron',
  time: '0 * * * *', // Hourly
  onTick: (client, job) => {
    console.log(`This cron executed at ${job.lastDate}`)
  }
});

Cron File Example

This example cron flushes throttle data within memory data managers. Options are the same as CronJob's constructor parameters, except a new parameter name must be given to identify the job, and context will not be used in the construction of a new cron job.

// ./src/crons/flushThrottles.cron.js

module.exports = {
  name: 'flush-throttles',
  time: '0 * * * *', // Hourly
  onTick: (client, job) => {
    this.client.data.flushThrottles()
  }
}

Keywords

FAQs

Package last updated on 22 Jun 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