# paramedic

> A simple health monitor server for running health checks periodically.

Latest version **0.0.3** (published 2012-08-06) · BSD license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install paramedic
pnpm add paramedic
yarn add paramedic
bun add paramedic
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2012-08-06 |
| First published | 2012-08-03 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+14 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | health, test, status, server |

## Links

- npm: https://www.npmjs.com/package/paramedic
- Repository: https://github.com/hughsk/paramedic
- Homepage: http://github.com/hughsk/paramedic
- npm.io page: https://npm.io/package/paramedic

## Dependencies (3)

- [moment](https://npm.io/package/moment.md) ~1.7.0
- [handlebars](https://npm.io/package/handlebars.md) ~1.0.6
- [underscore](https://npm.io/package/underscore.md) ~1.3.3

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2012-08-06
- 0.0.2 — 2012-08-04
- 0.0.1 — 2012-08-03

## README

# Paramedic

A simple health monitor server for running health checks periodically.

## Installation

``` bash
npm install paramedic
```

## Usage

**Step 1:** Create a new server.

``` javascript
var medic = require('paramedic').createServer()
```

**Step 2:** Load up your tests. There are two callbacks passed to each test:
`done` and `warn`. If you pass an error (or string) as the first argument to
either of these callbacks, the test will fail: `done` emits an error,
whereas `warn` only emits a warning.

``` javascript
var request = require('request')

medic.test('Google Australia', function(done, warn) {
    request.get('http://google.com.au/', function(err) {
        return done(err);
    });
}).interval(6000);

medic.test('Google UK', function(done, warn) {
    request.get('http://google.co.uk/', function(err) {
        return warn(err);
    });
}).interval(21000);
```

**Step 3:** Start up the server! `start()` returns a request callback for you
to easily plug into an HTTP server, or as an Express route.

``` javascript
var http = require('http')
  , server = medic.start();

http.createServer(server).listen(8080);
```

After that, your server should be running on port 8080, similar to this:

![Screenshot](https://github.com/hughsk/paramedic/raw/master/examples/http-polling.png)

### Collections

You can create "collections" of tests too. These function as reusable
templates, which can then be loaded using the collection's `add` method.

``` javascript
medic.collection('Google Queries', function(data) {
    this.test('http://google.com/?q=' + data.query, function(done, warn) {
        request.get(data.url, done);
    }).interval(data.interval);
}).add({
      query: 'lorem'
    , interval:  6000
}).add({
      query: 'lorem'
    , interval: 21000
});
```

### Events

The server page will update accordingly as tests fail and recover,
but the server also emits `error`, `warn`, `pass` and `recover` events.

This can be used, for example, to send notifications or automate a recovery.

`ready` is emitted when the server has started testing.

---
_Source: https://npm.io/package/paramedic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
