Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

herrtxbias-cachet-api

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

herrtxbias-cachet-api

An API client for Cachet, the open source status page system.

  • 1.0.15
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

cachet-api fork

Why?

The docker image provided by cachet has a nginx with cache set up in front of it. We want to get incidents in "realtime", so we don't want cached results.

The PR adding this feature was not accepted by the author of the original lib (and that's ok), so we forked it.


Original readme:

cachet-api

npm version

A Node.js API client for Cachet.

Cachet is a beautiful and powerful open source status page system, a free replacement to services such as StatusPage.io, Status.io and others.

Usage

First, install the package using npm:

npm install cachet-api --save

Then, start using the package by importing and configuring it:

var CachetAPI = require('cachet-api');

// Fill in the parameters accordingly
var cachet = new CachetAPI({
    // Base URL of your installed Cachet status page
    url: 'https://demo.cachethq.io',
    // Cachet API key (provided within the admin dashboard)
    apiKey: 'a1b2c3d4e5f6g7h8i9'
});

Make sure to fill in your Cachet status page url as well as your Cachet admin account's apiKey, which you can find in the Cachet dashboard.

Get Component Info

Use cachet.getComponentById(id) to fetch details about an existing component:

// Prepare a component ID to fetch
var componentId = 1;

// Get component info by ID
cachet.getComponentById(componentId)
    .then(function (component) {
        // Log component info
        console.log('Component', component);
    }).catch(function (err) {
        // Log errors to console
        console.log('Fatal Error', err);
    });

Publish a Metric Point

Use cachet.publishMetricPoint(point) to publish a new metric point to an existing metric:

// Prepare a metric point to publish (so it shows up on the metric's graph)
var metricPoint = {
    // Metric ID
    id: 1,
    // Metric point value
    value: 3.37,
    // Metric point timestamp (optional, defaults to now)
    timestamp: Math.round(new Date().getTime() / 1000)
};

// Publish it so it shows up on the status page
cachet.publishMetricPoint(metricPoint)
    .then(function (response) {
        // Log API response
        console.log('Metric point published at ' + response.data.created_at);
    }).catch(function (err) {
        // Log errors to console
        console.log('Fatal Error', err);
    });

Report an Incident

Use cachet.reportIncident(incident) to report a new status incident:

// Prepare an incident to report
var incident = {
    // Incident name
    name: 'Database connectivity issues',
    // Incident description (supports markdown)
    message: 'We\'re investigating connectivity issues with the main DB.',
    // Incident status (https://docs.cachethq.io/docs/incident-statuses)
    status: 'Investigating',
    // Whether the incident will be visible to the public or only to logged in users
    visible: true,
    // Whether to send out e-mail notifications to subscribers regarding this incident
    notify: true,
    // Component ID affected by this incident (optional)
    component_id: 1,
    // Component status (required if component_id is specified) (https://docs.cachethq.io/docs/component-statuses)
    component_status: 'Partial Outage'
};

// Report it so it shows up on the status page
cachet.reportIncident(incident)
    .then(function (response) {
        // Log API response
        console.log('New incident reported at ' + response.data.created_at);
    }).catch(function (err) {
        // Log errors to console
        console.log('Fatal Error', err);
    });

License

Apache 2.0

FAQs

Package last updated on 28 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc