Socket
Socket
Sign inDemoInstall

@octopod-service/notifier

Package Overview
Dependencies
206
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @octopod-service/notifier

[![npm Version](https://img.shields.io/npm/v/@octopod-service/notifier.svg)](https://www.npmjs.com/package/@octopod-service/notifier)


Version published
Weekly downloads
6
increased by500%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Notifier for octopod

npm Version

Install

npm install @octopod-service/notifier

Usage

// TypeScript
import * as notifier from '@octopod-service/notifier'
// JavaScript
const notifier = require('@octopod-service/notifier');

const notifierService = new notifier.NotifierService('http://...');

// Set option
notifierService.operations.push({
    type: 'write-file',
    settings: {
        path: '...'
    }
});

notifierService.types['write-file'] = function(type /* : DestinationType*/, data /* : Notification*/, callback /* : () => void*/)
{
    if(!type.settings.path)
    {
        this.error('Error in "write-file"', 'type.settings.path is not defined');
        return callback();
    }

    const retry = () => {
        require('fs').writeFile(type.settings.path, JSON.stringify(data), (e) => {
            if(!e)
                return callback(); // Success!

            this.error('Error in "write-file"', e);
            return setTimetout(() => retry(), type.retryTimeout ? type.retryTimeout : 10000); // If failed, retry later
        })
    }

    retry();
}

notifierService.start();

Call

this.writeToService<Notification>('notifier', 'notify', {
    title: 'title',
    body: 'body\r\nbody.',
    notify: {
        node: this.uid,
        type: this.options.username
    }
}, () => { });

FAQs

Last updated on 05 Aug 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc