Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including bragg-cron with all npm packages installed. Try it out:

var braggCron = require("bragg-cron")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

bragg-cron v1.0.0

Cronjob middleware for bragg

bragg-cron Build Status

Cronjob middleware for bragg

This little piece of middleware makes it possible to handle Cronjob events as if they where normal requests.

Install

$ npm install --save bragg-cron

Usage

const app = require('bragg')();
const router = require('bragg-router')();
const cron = require('bragg-cron');

router.post('cron:RuleName', ctx => {
    ctx.body = ctx.request.body;
});

app.use(cron());
app.use(router.routes());

exports.handler = app.listen();

The cron: prefix is attached by this module and is followed by the name of the rule that originated the event. The time at when the cronjob executed the function is provided in the body property of the request object.

API

cron()

Install the cron middleware

License

MIT © Sam Verschueren

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free