npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@leisurelink/hapi-adaptor

v1.0.0

Published

Provides plugins common to leisurelink adaptors

Downloads

1

Readme

@leisurelink/hapi-adaptor

Common plugins used in LeisureLink adaptors

Installation

npm install @leisurelink/hapi-adaptor

Usage

This module exposes several plugins. Because they rely on a multi-level dependency tree which hapi doesn't support very well, you should be sure to register the Configuration plugin, then the MagicBus plugin, and the EventPublisher plugin before any others.

import { Configuration, MagicBus, EventPublisher ... } from '@leisurelink/hapi-adaptor';

Plugins

Configuration

Provides environment-based configuration values.

server.register(Configuration)
// ...
let value = server.plugins.configuration.get('config_key');

MagicBus

Creates a MagicBus broker for use throughout your application. Requires that the Configuration plugin has been loaded. The plugin's register function uses the following options:

  • serviceDomainName - Passed to magicbus.createBroker
  • appName - Passed to magicbus.createBroker
  • connectionInfo - Passed to magicbus.createBroker
    • If not present, configuration.get('RABBITMQ_URL') is used
    • If no RABBITMQ_URL value is present, then these options are used to build connection info:
      • RABBITMQ_HOST
      • RABBITMQ_PORT
      • RABBITMQ_USER
      • RABBITMQ_PASS
server.register(MagicBus, { appName: 'my-app' });
// ...
let connectionInfo = server.plugins.magicbus.connectionInfo
let broker = server.plugins.magicbus.broker;

Event Publisher

Provides an easy way to publish an event to magicbus. Requires that the MagicBus plugin has been loaded.

server.register(EventPublisher)
// ...
server.plugins['event-publisher'].publish('my-event-type', { some: 'data' });

Hook Router

Publishes events that come in on a route to the magic bus. Requires that the EventPublisher plugin has been loaded. The plugin's register function uses the following options:

  • eventType - global event type used for all published events (can be overridden per event)
  • routes - array of routes to listen on
    • method - HTTP method (usually 'POST' or 'GET')
    • path - the path to register
    • eventType - the event type to publish
    • response - either a response object (passed to reply) or a function with the signature function (request, reply) that is called to generate a response. This should be a lightweight function only intended to generate a response, any work should be in the magicbus event handler. Defaults to { status: 'success' }
server.register(HookRouter, { eventType: 'my-adaptor-hooks', routes: [ { method: 'POST', path: '/hooks/leisurelink', response: 'OK' }] });

LeisureLink Client

Wraps the leisurelink-hub-client npm package with initialization from the Configuration plugin. Requires the Configuration and EventPublisher plugins be loaded. Will publish all API traffic to magic bus with the event type 'llapi-traffic', useful for logging api traffic. The plugin's register function uses the following options:

  • apiKey - the api key to use for communicating with LeisureLink's API. If not present, retrieved from LEISURELINK_API_KEY
  • url (optional) - the URL where LeisureLink's API is available. If not present, retrieved from LEISURELINK_HUB_URL or defaulted to client's default value.
  • version (optional) - which version of the API to use. Defaults to 'v1'
server.register(LeisureLinkClient, { version: 'v1' });
//server.plugins['leisurelink-client'] contains all methods available on the instantiated client.

Mapping

Exposes functions used to retrieve mappings from the common ID mapping service (aka Bonanza). Requires the Configuration plugin be loaded. The plugin's register function uses the following options:

  • host - the host of the mapping service, like https://mapping-service.leisurelink.local/. If not present, retrieved from BONANZA_URL
  • keyId - the id of the key used to sign the requests. If not present, retrieved from KEY_ID
  • key - a Buffer object containing the key to sign with. If not present, keyFile is used
  • keyFile - path to a key file used to sign requests. If not present, retrieved from KEY_FILE
server.register(Mapping);
//...
let connectionTypes = server.plugins.mapping.connectionTypes;
let mapping = await server.plugins.mapping.get(targetDomain, connectionType, mapping);
let connections = await server.plugins.mapping.getAll(targetDomain, connectionType);

Transmogrify

Exposes functions used to transform data. Eventually will call LeisureLink's transmogrify service, but just runs the transforms in process today. The plugin's register function uses the following options:

  • transformPath - where the transform files are located.
server.register(Transmogrify, { transformPath: __dirname });
//...
let results = await server.plugins.transmogrify.executeAll(['data-to-availability', 'data-to-stay-restrictions']);
let avail = results['data-to-availability'];