heart-ping
TypeScript icon, indicating that this package has built-in type declarations

2.0.9 • Public • Published

Heart Ping

License Current Version npm

A simple light-weight Typescript module for pinging HTTP services at set intervals to provide a heartbeat.

Installation

yarn add heart-ping

Usage

import HeartPing from 'heart-ping';

const heartPing = new HeartPing();
heartPing.setBeatInterval(10_000);
heartPing.setBeatTimeout(30_000);
heartPing.setOnTimeout(() => {
  console.log('The ping request to www.google.com has timed out!');
});
heartPing.start(
  'www.google.com', // or using https, e.g.: 'https://www.google.com'
  80,
  (time) => {
    console.log(`Successfully pinged www.google.com! It took ${time} milliseconds.`);
  },
  () => {
    console.log('Failed to ping www.google.com!');
  },
);

License

MIT License

Contributing

Contributions are encouraged, please see further details below:

Pull Requests

Here are some basic rules to follow to ensure timely addition of your request:

  1. Match coding style (braces, spacing, etc.).
  2. If it is a feature, bugfix, or anything please only change the minimum amount of code required to satisfy the change.
  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge.
  4. Pull requests must be made against the main branch. Any other branch (unless specified by the maintainers) will get rejected.
  5. Check for existing issues first, before filing a new issue.

Package Sidebar

Install

npm i heart-ping

Weekly Downloads

1

Version

2.0.9

License

MIT

Unpacked Size

15.3 kB

Total Files

6

Last publish

Collaborators

  • nicolaspearson