open-index/open-npm huggingface dataset:
npm package: @pager/hapi-redis
Description: A redis hapi plugin
Author: Gaston Festari
Latest version: 2.1.7

# hapi-redis

A [node-redis] hapi plugin

[![CircleCI](https://circleci.com/gh/pagerinc/hapi-redis.svg?style=svg)](https://circleci.com/gh/pagerinc/hapi-redis)

## Installation

```
npm install --save @pager/hapi-redis
```

## Quick start

This pretty much works as a regular node-redis client, with the addition of providing an easily accessible instance via the [`server.app`](http://hapijs.com/api#serverapp) common namespace.

## Examples

```js
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ host: 'localhost' });

const options = {
    // node-redis config options - http://redis.js.org/#api-rediscreateclient
};

// Register the plugin
server.register({
    register: require('@pager/hapi-redis'),
    options: options
}, (err) => {

    if (err) {
        console.error(err);
    } 
    else {
        server.start(() => {

            console.info(`Server started at ${server.info.uri}`);
        });
    }
});

// Declare a route that uses it
server.route({
    method: 'GET',
    path: '/stats',
    handler: usersHandler
});

usersHandler (request, reply) => {

    // Access the redis instance
    const client = request.redis;
    client.hgetall('users', (err, obj) => {
    
        if (err) {
            throw err
        }

        return reply({ result: obj });
    });
};

server.start(() => {
    console.log(`Server started at ${server.info.uri}`);
});
```

## Async support
You could use next promisified methods, e.g.: 

```javascript
const res = await getAsync(key);
```

| Original method | Promisified method |
| --------------- | ------------------ |
| set             | setAsync           |
| get             | getAsync           |
| flushall        | flushallAsync      |
| quit            | quitAsync          |
| keys            | keysAsync          |
| ttl             | ttlAsync           |

## Tests

To run the test suite, first install the dependencies, then run `npm test`:

```bash
$ npm install
$ npm test
```

## Versions
 - Use 1.x.x for hapi@16
 - Use 2.x.x for hapi@17 or later

## Acknowledgements

This module borrows heavily from [hapi-ioredis].

[node-redis]: https://github.com/NodeRedis/node_redis
[hapi-ioredis]: https://github.com/cilindrox/hapi-ioredis
npm package: @pager/jackrabbit
Description: Easy RabbitMQ for node
Author: Pager Developers
Latest version: 5.7.0

# Jackrabbit

This is a fork of [hunterloftis/jackrabbit].

[![CircleCI](https://circleci.com/gh/pagerinc/jackrabbit.svg?style=svg)](https://circleci.com/gh/pagerinc/jackrabbit)

Jackrabbit is a very opinionated abstraction built on top of `amqplib` focused
on usability and implementing several messaging patterns on RabbitMQ.

## Simple Example

```js
// producer.js
'use strict';

const jackrabbit = require('@pager/jackrabbit');
const rabbit = jackrabbit(process.env.RABBIT_URL);

rabbit
  .default()
  .publish('Hello World!', { key: 'hello' })
  .on('drain', rabbit.close);
```

```js
// consumer.js
'use strict';

const jackrabbit = require('@pager/jackrabbit');
const rabbit = jackrabbit(process.env.RABBIT_URL);

rabbit
  .default()
  .queue({ name: 'hello' })
  .consume(onMessage, { noAck: true });

function onMessage(data) {
  console.log('received:', data);
}
```

## Ack/Nack Consumer Example

```js
'use strict';

const jackrabbit = require('@pager/jackrabbit');
const rabbit = jackrabbit(process.env.RABBIT_URL);

rabbit
  .default()
  .queue({ name: 'important_job' })
  .consume(function(data, ack, nack, msg) {
    // process data...
    // and ACK on success
    ack();
    // or alternatively NACK on failure
    nack();
  })
```

## More Examples

For now, the best usage help is can be found in [examples](https://github.com/pagerinc/jackrabbit/tree/master/examples),
which map 1-to-1 with the official RabbitMQ tutorials.

## Installation

```
npm install --save @pager/jackrabbit
```

## Tests

The tests are set up with Docker + Docker-Compose,
so you don't need to install rabbitmq (or even node)
to run them:

```
$ docker-compose up
```

[hunterloftis/jackrabbit]: https://github.com/hunterloftis/jackrabbit

## Reconnection
> Jackrabbit is a wrapper for [ampqlib](https://github.com/amqp-node/amqplib), ampqlib does NOT support reconnection.

This project will try to recover a lost connection gracefully, if it fails to do so, we will throw an `error` event and then exit the current process with code `1`.

Our approach to reconnection is recording all the exchanges and queues created through jackrabbit. Once a connection is lost, we will try to create a new one, update the existing exchange and queue references, initialize a new channel for each queue, and bind each queue's consumers to their new channel. This should be transparent to any users of this lib.

You can configure some basic parameters of the reconnection process with some env vars:

Name|Default|Description
-|-|-
`RABBIT_RECONNECTION_TIMEOUT`| 2000 | ms between each reconnection attempt. The first attempt will always be immediate.
`RABBIT_RECONNECTION_RETRIES`| 20 | Amount of retries before erroring out and killing the node process.
`RABBIT_RECONNECTION_EXACT_TIMEOUT` | false | To prevent total outages on HA services, we're adding a random overhead of 0-10% to the reconnection timeout by default. You can disable this behaviour by setting this option to `true`.
npm package: @pager/json-markdown
Description: Generate Markdown documentation for your JSON schema
Latest version: 1.0.8

# json-markdown

This Project is fork of https://github.com/jeremyrajan/json-markdown. It is forked to mantain dependencies.

[![Build Status](https://travis-ci.org/jeremyrajan/json-markdown.svg?branch=master)](https://travis-ci.org/jeremyrajan/json-markdown)

## About
json-markdown is a simple tool to generate documentation for your JSON schema. The lib provides a CLI api and pro-grammatical api for use in your applications.

## Usage

```
npm install --save [-g] json-markdown
```

### CLI
```
json-markdown <location-to-your-file.json> --w=true/false
```

You can pass -w=true/false, if you want to write to a file or not. By default its true.

This will generate the markdown from your schema and create `SCHEMA.md` in the current directory. You can also provide an output file, to which you want to write:

```
json-markdown <location-to-your-file.json> <output-file-location.md> --w=true/false
```

### API usage.
```javascript
const jsonmarkdown = require('json-markdown');
const schemaLoc = './product.json';
const outputFile = 'output-file.md'; // if you don't provide an output file, it will create an .md from your schema filename.
// the third argument defines, if you want to write to file or not. Set it to false, if you dont need to create a markdown yet.
jsonmarkdown.process(schemaLoc, outputFile, true, (err, result) => {
  console.log(result);
});

```

Report issues: https://github.com/jeremyrajan/jsonschema-md/issues

Hope it helps, someone :).
npm package: @pager/minion-army
Description: Microservice Framework for RabbitMQ Workers
Author: engineering@pager.com
Latest version: 2.3.1

# minion-army
Microservice Framework for RabbitMQ Workers

## usage

```javascript
const Army = require('@pager/minion-army');
const Joi = require('joi');

// Refer to lib/schema.js to see valid options
const manifest = {
    connection: { // optional, if not provided will default to a rabbit connection to local host
        rabbitUrl: 'amqp://localhost'
    },
    defaults: { // default values that apply for all workers
        exchangeName: 'my-exchange-name'
    },
    workers: [
        {
            handler: (message) => console.log('my job is to log this', message),
            config: { // same config as expected by minions
                name: 'jobs.logging',
                key: 'events.something.happened'
            },
            validate: Joi.object({ // set a joi schema to validate handler input (optional)
                id: Joi.string().required()
            })
        },
        {
            handler: (message) => true,
            config: {
                name: `jobs.trueing`,
                key:  `events.something.happened`
            }
        }
    ]
};

const army = Army(manifest);

army.start(); // if you provide defaults.autoStart = true this is not needed
```
npm package: @pager/minion-joi
Description: Joi validation for pager/minion workers
Author: gmauricio.munoz@gmail.com, david.roncancio@gmail.com
Latest version: 1.1.0

**Minion-joi**  —  _Joi validation for pager/minion workers_

## Usage Example

```javascript
const validation = require('minion-joi')

const validator = validation(Joi.object({
    foo: Joi.string().required()
}))

const handler = (message) => {
   return `Hello ${message.foo}`
}

module.exports = validator(handler)
```

By default minion will nack and not requeue messages on failure, if you want the message to be requeued after failing validation you can do it like this:

```javascript
const validation = require('minion-joi')

const validator = validation(Joi.object({
    foo: Joi.string().required()
}), { requeue: false })

const handler = (message) => {
   return `Hello ${message.foo}`
}

module.exports = validator(handler)
```