npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cachet-node

v0.1.1

Published

Cachet API implementation

Downloads

7

Readme

cachet-node

cachet-node is an implementation of the Cachet API. This API is automatically generated based on a swagger documentation file on cachet-swagger through the use of swagger-js-codegen.

Currently it supports the following operations from the Cachet API Reference:

  • General
  • Components
  • Component Groups
  • Incidents
  • Incident Updates
  • Metrics

Table of Contents

Usage

Basics

In order to start leveraging the cachet-node library you will generally have an API key located under your Teams -> User area. This is going to be necessary to do anything that is not a read-only event. You only need to set this information once you have initialized the library.

const Cachet = require('cachet-node').Cachet;

const cachet = new Cachet({
  domain: 'https://status.yourdomain.com/api/v1',
  token: {
    value: 'token value from user',
    headerOrQueryName: 'X-Cachet-Token'
  }
});

Now you can start to leverage one of the many functions such as fetching the current version:

cachet.version()
  .then(response => {
    console.log(response.body);
    // { meta: { on_latest: true, latest: { tag_name: 'v2.3.10', prelease: false, draft: false } }, data: '2.4.0-dev' }
  })
  .catch(err => {
    console.log(err);
  });

Note that all of the methods will provide back a promise with the exception of the setToken method (not documented as you can use the constructor).

This library also makes heavy use of a request object, what you are receiving back is the what the request provides raw and that is where you will need to utilize the "body" parameter.

Parameters

Note that all parameters must be passed in via a JavaScript object. Anytime you are creating, it requires a body parameter. You can find such parameters in the swagger file in cachet-swagger until this documentation reflects all of the methods and functionality of the endpoint.

General

ping

Ping the status system to ensure it is available.

Request
cachet.ping()
Response
{
  "data": "Pong!"
}

version

Fetch the current version of the system.

Request
cachet.version()
Response
{
  "meta": {
    "on_latest": true,
    "latest": {
      "tag_name": "v2.3.10",
      "prelease": false,
      "draft": false
    }
  },
  "data": "2.4.0-dev"
}

Components

getComponents

Fetch all of the components.

Parameters
  • sort
  • order
  • perPage
  • page
  • id
  • name
  • status
  • groupId
  • enabled
Request
cachet.getComponents({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": 20,
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "name": "Example",
      "description": "",
      "status": 1,
      "order": 0,
      "group_id": 1,
      "created_at": "2017-01-05 16:52:00",
      "updated_at": "2017-01-06 02:27:32",
      "deleted_at": null,
      "enabled": true,
      "meta": null,
      "link": "https://status.example.com",
      "status_name": "Operational",
      "tags": {
        "": ""
      }
    }
  ]
}

getComponentById

Parameters
  • component
Request
cachet.getComponentById({
  component: 4
})
Response
{
  "data": {
    "id": 4,
    "name": "Foo",
    "description": "",
    "status": 0,
    "order": 0,
    "group_id": 0,
    "created_at": "2017-01-06 19:51:29",
    "updated_at": "2017-01-06 19:52:59",
    "deleted_at": null,
    "enabled": false,
    "meta": null,
    "link": "",
    "status_name": "Unknown",
    "tags": []
  }
}

createComponent

Parameters
  • body
    • name
    • description
    • status
    • link
    • order
    • group_id
    • enabled
Request
cachet.createComponent({
  body: {
    name: 'Foo'
  }
})
Response
{
  "data": {
    "order": 0,
    "group_id": 0,
    "description": "",
    "link": "",
    "enabled": true,
    "meta": null,
    "name": "Foo",
    "status": 0,
    "updated_at": "2017-01-06 19:51:29",
    "created_at": "2017-01-06 19:51:29",
    "id": 4,
    "status_name": "Unknown",
    "tags": []
  }
}

updateComponentById

Parameters
  • component
  • body
    • name
    • status
    • link
    • order
    • group_id
    • enabled
Request
cachet.createComponent({
  component: 4,
  body: {
    enabled: 0
  }
})
Response
{
  "data": {
    "id": 4,
    "name": "Foo",
    "description": "",
    "status": 0,
    "order": 0,
    "group_id": 0,
    "created_at": "2017-01-06 19:51:29",
    "updated_at": "2017-01-06 19:52:59",
    "deleted_at": null,
    "enabled": false,
    "meta": null,
    "link": "",
    "status_name": "Unknown",
    "tags": []
  }
}

deleteComponentById

Parameters
  • component
Request
cachet.deleteComponentById({
  component: 4
})
Response

There is no response for this other than the status code.

Component Groups

getComponentGroups

Parameters
  • id
  • name
  • collapsed
  • sort
  • order
  • perPage
  • page
Request
cachet.getComponentGroups({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": 20,
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "name": "Example Group",
      "created_at": "2017-01-05 16:52:50",
      "updated_at": "2017-01-05 16:53:23",
      "order": 0,
      "collapsed": 0,
      "visible": 1,
      "enabled_components": [
        {
          "id": 1,
          "name": "Example",
          "description": "",
          "status": 1,
          "order": 0,
          "group_id": 1,
          "created_at": "2017-01-05 16:52:00",
          "updated_at": "2017-01-06 02:27:32",
          "deleted_at": null,
          "enabled": true,
          "meta": null,
          "link": "https://status.example.com",
          "status_name": "Operational",
          "tags": {
            "": ""
          }
        }
      ],
      "enabled_components_lowest": [
        {
          "id": 1,
          "name": "Example",
          "description": "",
          "status": 1,
          "order": 0,
          "group_id": 1,
          "created_at": "2017-01-05 16:52:00",
          "updated_at": "2017-01-06 02:27:32",
          "deleted_at": null,
          "enabled": true,
          "meta": null,
          "link": "https://status.example.com",
          "status_name": "Operational",
          "tags": {
            "": ""
          }
        }
      ],
      "lowest_human_status": "Operational"
    }
  ]
}

createComponentGroup

Parameters
  • name
  • order
  • collapsed
Request
cachet.createComponentGroup({
  body: {
    name: 'Foo Group'
  }
})
Response
{
  "data": {
    "order": 0,
    "collapsed": 0,
    "visible": 0,
    "name": "Foo Group",
    "updated_at": "2017-01-06 20:06:49",
    "created_at": "2017-01-06 20:06:49",
    "id": 2,
    "lowest_human_status": null
  }
}

getComponentGroupById

Parameters
  • group
Request
cachet.getComponentGroupById({
  group: 2
})
Response
{
  "data": {
    "id": 2,
    "name": "Foo Group",
    "created_at": "2017-01-06 20:06:49",
    "updated_at": "2017-01-06 20:06:49",
    "order": 0,
    "collapsed": 0,
    "visible": 0,
    "enabled_components": [],
    "enabled_components_lowest": [],
    "lowest_human_status": null
  }
}

updateComponentGroupById

Parameters
  • group
  • body
    • name
    • order
    • collapsed
Request
cachet.updateComponentGroupById({
  group: 2,
  body: {
    order: 10
  }
})
Response
{
  "data": {
    "id": 2,
    "name": "Foo Group",
    "created_at": "2017-01-06 20:06:49",
    "updated_at": "2017-01-06 20:09:43",
    "order": 10,
    "collapsed": 0,
    "visible": 0,
    "enabled_components": [],
    "enabled_components_lowest": [],
    "lowest_human_status": null
  }
}

deleteComponentGroupById

Parameters
  • group
Request
cachet.deleteComponentGroupById({
  group: 2
})
Response

There is no response for this other than the status code.

Incidents

getIncidents

Parameters
  • id
  • componentId
  • name
  • status
  • visible
  • sort
  • order
  • perPage
  • page
Request
cachet.getIncidents({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": "20",
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "component_id": 0,
      "name": "Incident Name",
      "status": 4,
      "visible": 1,
      "message": "Incident Message",
      "scheduled_at": "2015-08-01 12:00:00",
      "created_at": "2015-08-01 12:00:00",
      "updated_at": "2015-08-01 12:00:00",
      "deleted_at": null,
      "human_status": "Fixed"
    }
  ]
}

createIncident

Parameters
  • body
    • name
    • message
    • status
    • visible
    • component_id
    • component_status
    • notify
    • created_at
    • template
    • vars
Request
cachet.createIncident({
  body: {
    name: 'Incident Name',
    message: 'Incident Message',
    status: 4,
    visible: 1
  }
})
Response
{
  "data": {
    "id": 1,
    "component_id": 0,
    "name": "Incident Name",
    "status": 4,
    "visible": 1,
    "message": "Incident Message",
    "scheduled_at": "2015-08-01 12:00:00",
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:00",
    "deleted_at": null,
    "human_status": "Fixed"
  }
}

getIncidentById

Parameters
  • incident
Request
cachet.getIncidentById({
  incident: 1
})
Response
{
  "data": {
    "id": 1,
    "component_id": 0,
    "name": "Incident Name",
    "status": 4,
    "visible": 1,
    "message": "Incident Message",
    "scheduled_at": "2015-08-01 12:00:00",
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:00",
    "deleted_at": null,
    "human_status": "Fixed"
  }
}

updateIncidentById

Parameters
  • incident
  • body
    • name
    • message
    • status
    • visible
    • component_id
    • component_status
    • notify
Request
cachet.updateIncidentById({
  incident: 1,
  body: {
    name: 'Foo'
  }
})
Response
{
  "data": {
    "id": 1,
    "component_id": 0,
    "name": "Foo",
    "status": 4,
    "visible": 1,
    "message": "Incident Message",
    "scheduled_at": "2015-08-01 12:00:00",
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:01",
    "deleted_at": null,
    "human_status": "Fixed"
  }
}

deleteIncidentById

Parameters
  • incident
Request
cachet.deleteIncidentById({
  incident: 1
})
Response

There is no response for this other than the status code.

getIncidentUpdatesById

Parameters
  • incident
  • sort
  • order
  • perPage
  • page
Request
cachet.getIncidentUpdatesById({
  incident: 1
})
Response
{
  "meta":{
    "pagination":{
      "total":4,
      "count":4,
      "per_page":20,
      "current_page":1,
      "total_pages":1,
      "links":{
        "next_page":null,
        "previous_page":null
      }
    }
  },
  "data":[
    {
      "id":1,
      "incident_id":1,
      "status":4,
      "message":"The monkeys are back and rested!",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Fixed",
      "permalink":"http://cachet.app/incidents/1#update-1"
    },
    {
      "id":2,
      "incident_id":1,
      "status":3,
      "message":"Our monkeys need a break from performing. They'll be back after a good rest.",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Watching",
      "permalink":"http://cachet.app/incidents/1#update-2"
    },
    {
      "id":3,
      "incident_id":1,
      "status":2,
      "message":"We have identified the issue with our lovely performing monkeys.",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Identified",
      "permalink":"http://cachet.app/incidents/1#update-3"
    },
    {
      "id":4,
      "incident_id":2,
      "status":3,
      "message":"We're actively watching this issue, so it remains unresolved.",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Watching",
      "permalink":"http://cachet.app/incidents/2#update-4"
    }
  ]
}

getIncidentUpdateById

Parameters
  • incident
  • update
Request
cachet.getIncidentUpdateById({
  incident: 1,
  update: 1
})
Response
{
  "data": {
    "id":1,
    "incident_id":1,
    "status":4,
    "message":"The monkeys are back and rested!",
    "user_id":1,
    "created_at":"2016-12-05 19:37:20",
    "updated_at":"2016-12-05 19:37:20",
    "human_status":"Fixed",
    "permalink":"http://cachet.app/incidents/1#update-1"
  }
}

Metrics

getMetrics

Parameters
  • sort
  • order
  • perPage
  • page
Request
cachet.getMetric({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": "20",
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "name": "Coffee",
      "suffix": "Cups",
      "description": "Cups of coffee consumed.",
      "default_value": "0.000",
      "calc_type": 1,
      "display_chart": 1,
      "created_at": "2015-08-01 12:00:00",
      "updated_at": "2015-08-01 12:00:00",
      "default_view_name": "Last 12 Hours"
    }
  ]
}

createMetric

Parameters
  • body
    • name
    • suffix
    • description
    • default_value
    • display_chart
Request
cachet.createMetric({
  body: {
    name: "Visitors",
    description: "How many visitors",
    suffix: "Visitors per hour",
    default_value: 0,
    display_chart: 1
  }
}
Response
{
  "name":"Visitors",
  "description":"How many visitors",
  "suffix":"Visitors per hour",
  "default_value":"0",
  "display_chart":"1"
}

getMetricById

Parameters
  • metric
Request
cachet.getMetricById({
  metric: 1
})
Response
{
  "data": {
    "id": 1,
    "name": "Coffee",
    "suffix": "Cups",
    "description": "Cups of coffee consumed.",
    "default_value": "0.000",
    "calc_type": 1,
    "display_chart": 1,
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:00",
    "default_view_name": "Last 12 Hours"
  }
}

deleteMetricById

Parameters
  • metric
Request
cachet.deleteMetricById({
  metric: 1
})
Response

There is no response for this other than the status code.

getMetricPointsById

Parameters
  • metric
  • sort
  • order
  • perPage
  • page
Request
cachet.getMetricPointsById({
  metric: 1
})
Response
{
  "data": [
    {
      "id": 1,
      "metric_id": 1,
      "value": 1,
      "created_at": "2015-03-11 14:21:44",
      "updated_at": "2015-03-11 14:21:44"
    },
    {
      "id": 2,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:22:11",
      "updated_at": "2015-03-11 14:22:11"
    },
    {
      "id": 3,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:34:55",
      "updated_at": "2015-03-11 14:34:55"
    }
  ]
}

createMetricPointById

Parameters
  • metric
  • body
    • value
    • timestamp
Request
cachet.createMetricPointById({
  metric: 1,
  body: {
    value: 3
    timestamp: '2015-03-11 14:34:55'
  }
}
Response
{
  "data": [
    {
      "id": 1,
      "metric_id": 1,
      "value": 1,
      "created_at": "2015-03-11 14:21:44",
      "updated_at": "2015-03-11 14:21:44"
    },
    {
      "id": 2,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:22:11",
      "updated_at": "2015-03-11 14:22:11"
    },
    {
      "id": 3,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:34:55",
      "updated_at": "2015-03-11 14:34:55"
    }
  ]
}

deleteMetricPointById

Parameters
  • metric
  • point
Request
cachet.deleteMetricPointById({
  metric: 1,
  point: 3
})
Response

There is no response for this other than the status code.

Contributing

Contributions in this repository can be documentation and/or build changes. Since the code is automatically generated no changes to the index.js file will be taken.