Code Monkey home page Code Monkey logo

agenda-rest's Introduction

npm version Build Status Slack Status

agenda-rest

Scheduling as a Service, based on Agenda

Assuming all job types could be thought of as REST endpoints, scheduling could be offered as a service. agenda-rest does just that, introduce a URL, name it, agenda-rest will call it on the times that you specify.

Installation

Install agenda-rest as a global package

npm install -g agenda-rest

Usage

To launch the agenda-rest server, use the command line interface specifying the database host name and the database name

agenda-rest --dbhost localhost --dbname agenda

Command Line Interface options

Options Description
-d, --dbname [optional] Name of the Mongo database, default is agenda
-h, --dbhost [optional] Mongo instance's IP or domain name, default is localhost
-u, --dburi [optional] Full Mongo connection string. If specified, will override --dbhost, --dbname
-p, --port [optional] agenda-rest server port, default is 4040
-k, --key [optional] x-api-key to be expected in headers. If not specified, access to agenda-rest server would be unauthenticated
-t, --timeout [optional] Timeout for request duration, default is 5000 ms

APIs

GET /api/job

Get a list of defined jobs

  • Method: GET

POST /api/job

Defines a new category of jobs

  • Method: POST
  • Data:
{
    name,           // New job type's name
    url,            // koa-router style url
    method,         // (optional) Request type, default: POST
    callback: {     // (optional) to call with response after invocation
        url,
        method,
        headers
    }
}

PUT /api/job/:jobName

Updates definition of a job category

  • Method: PUT
  • Data: same as POST /api/job

DELETE /api/job/:jobName

Deletes job definition and cancels occurrences

  • Method: DELETE

POST /api/job/once & POST /api/job/every

Schedule a job for single or multiple occurrences

  • Method: POST
  • Data:
{
    name,           // Name of the type to create the instance from
    interval,       // Interval in which job should be invoked (human-interval, can also be a date string for 'once')
    data: {         // (optional) default: {}
        headers,    // Http headers, e.g. { Authorization: '<token>' }
        params,     // Path parameters, to replace `:param` notations in job definition's url
        query,      // Query parameters (?foo=bar&baz=qux)
        body        // Accompanying data sent along the request
    }
}

Callback, if present, would be invoked by the following object:

{
    data: {
        // passed data object, same as above
    },
    response        // response from invocation
}

POST /api/job/now

Like once and every, though without interval. Executes the job now.

POST /api/job/cancel

Cancels (not to be confused with 'delete') any jobs matching the query

  • Method: POST
  • Data: Mongo query
{
    name: "foo"
}

agenda-rest's People

Contributors

abhijitmehta avatar arvant avatar chickencoder avatar dyoxyne avatar farhoud avatar keyvan-m-sadeghi avatar omgimalexis avatar qlonik avatar renovate-bot avatar renovate[bot] avatar sampathblam avatar simison avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.