New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@slimio/alert

Package Overview
Dependencies
Maintainers
5
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slimio/alert

Alert for SlimIO

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
5
Weekly downloads
 
Created
Source

Alert

V1.0 Maintenance MIT

Requirements

  • Node.js v10 or higher

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/alert
# or
$ yarn add @slimio/alert

Usage example

A simple addon that will throw an alarm every second...

// Require Dependencies
const Addon = require("@slimio/addon");
const alert = require("@slimio/alert");
const metrics = require("@slimio/metrics");

// Declare addons
const test = new Addon("test");
const { Entity } = metrics(test);
const { Alarm } = alert(test);

let intervalId;
const MyEntity = new Entity("MyEntity", {
    description: "Hello world!"
});

test.on("awake", () => {
    intervalId = setInterval(() => {
        new Alarm("hello world!", {
            correlateKey: "test_alarm",
            entity: MyEntity
        });
    }, 1000);

    test.ready();
});

test.on("close", () => {
    clearInterval(intervalId);
});

module.exports = test;

API

The alert package return a function described by the following interface:

declare function Alert(addon: Addon): {
    Alarm: typeof Alarm;
};

Each instance of Alarm are unique to the local Addon.

Alarm

This section describe the methods and properties of Alarm Object.

constructor(message: string, options: Alert.ConstructorOptions)

Create a new Alarm Object.

new Alarm("hello world alarm", {
    correlateKey: "test_alarm"
});

Available options are described the following interface:

interface ConstructorOptions {
    severity?: SlimIO.AlarmSeverity;
    entity?: Metrics.Entity | string | number;
    correlateKey: string;
}
toJSON(): SlimIO.RawAlarm

Return a raw alarm. Refer to @slimio/tsd for more information.

Properties
declare class Alarm extends events {
    public cid: SlimIO.CID;
    public severity: number;
    public entity: Metrics.Entity | number;
    public message: string;
    public correlateKey: string;

    static DefaultSeverity: number;
    static Severity: SlimIO.AlarmSeverity;
}

Severity is defined in @slimio/tsd as follow:

enum AlarmSeverity {
    Critical,
    Major,
    Minor
}

The default severity is defined as 1 for Major.

License

MIT

Keywords

FAQs

Package last updated on 10 Apr 2019

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