0.0.0-experimental.1 • Published 1 year ago

@kingworldjs/cron v0.0.0-experimental.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@kingworldjs/cron

A plugin for kingworld that add support for running cronjob.

Installation

bun add @kingworldjs/cron

Example

import { KingWorld } from 'kingworld'
import '@kingworldjs/cron'

const app = new KingWorld()
    .cron({
        name: 'heartbeat',
        pattern: '*/1 * * * * *'
    }, () => {
        console.log("Heartbeat")
    })
    .get('/stop', ({ store: { cron: { heartbeat } } }) => {
        heartbeat.stop()

        return 'Stop heartbeat'
    })
    .listen(8080)

API

This plugin extends cron method to KingWorld using cronner

For documentation, app.cron use the same syntax as cronner, so please refers to cronner documentation