cogsworth-micro

0.0.5 • Public • Published

cogsworth-micro

a cogsworth microservice.

rad! 💯

usage

launch

require('cogsworth-micro')
.start()
.then(observable => {
  return observable.forEach(evt => {
    const { schedule: { id }, trigger: { date } } = evt
    console.log(`schedule ${id} fired at ${date}`)
  })
})

routes

the following routes are supported:

// get /
// get /:id
// post /
// put /:id
// delete /:id

the payload of a schedule is:

// [brackets] imply the field is optional
{
  [id]: 'best_id',
  trigger: { // at least one of the below must be provided
    [cron]: '* * * * * *', // pattern
    [rrule]: 'FREQ=SECONDLY', // pattern
    [vevent]: `
      [DTSTART:2017-07-15T07:41:25.815Z]
      RRULE:FREQ=SECONDLY
    `
  }
}

demo

node ./example.js, from the micro source code

🛰  micro$ node example.js
  koa:application use bodyParser +0ms
  koa:application use simpleResponses +2ms
  koa-route GET / -> /^(?:\/(?=$))?$/+2ms
  koa:application use - +0ms
  koa-route GET /:id -> /^\/((?:[^\/]+?))(?:\/(?=$))?$/+0ms
  koa:application use - +0ms
  koa-route POST / -> /^(?:\/(?=$))?$/+0ms
  koa:application use - +0ms
  koa-route PUT /:id -> /^\/((?:[^\/]+?))(?:\/(?=$))?$/+1ms
  koa:application use - +0ms
  koa-route DELETE /:id -> /^\/((?:[^\/]+?))(?:\/(?=$))?$/+0ms
  koa:application use - +0ms
listening on port 8080
  koa:application listen +3ms
  cogsworth:Scheduler scheduler state: STARTING +0ms
  cogsworth:Scheduler scheduler state: RUNNING +1ms

Package Sidebar

Install

npm i cogsworth-micro

Weekly Downloads

2

Version

0.0.5

License

MIT

Last publish

Collaborators

  • cdaringe