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

jackal

v2.0.15

Published

Consumer Driven Contracts Service

Downloads

76

Readme

Jackal

npm npm Build Coverage Known Vulnerabilities Contributors License Docker Pulls

A microservice for consumer-driven contract testing. Read about Jackal on the findmypast tech blog.

Docs

Quick Start

Running Locally

To install Jackal

npm i -g jackal

To start a local instance of the Jackal server with the default configuration:

jackal start

Alternatively, to specify a custom configuration file:

# Using a JSON configuration file
jackal start -c /path/to/custom/config.json

# Using a YAML configuration file
jackal start -c /path/to/custom/config.yaml

We recommend defining a custom configuration file, both JSON and YAML formats are supported, see the Jackal Configuration Guide for more information. The default configuration is as follows:

db:
  path: db.json
logger:
  environment: development
statsD:
  host: localhost
  port: 8125
  prefix: jackal

Jackal should now be available at http://localhost:25863. A health endpoint is provided at /api/health.

Running on Docker

To start a dockerised instance of Jackal with the default configuration:

docker run -p 25863:25863 findmypast/jackal

Jackal should now be available at http://localhost:25863. A health endpoint is provided at /api/health.

Testing Contracts as a Consumer

Contracts File

Make sure to define a contracts file, e.g:

itunes_search_app:                # consumer name
  itunes:                         # provider name
    search_by_term_and_country:   # api endpoint name
      OK:                         # scenario name
        request:
          baseUrl: 'https://itunes.apple.com'
          path: '/search'
          query: '?term=mclusky&country=gb'
          method: GET
          headers:
            Header-Name: headerValue
            Another-Header-Name: headerValue
          timeout: 1000
        response:
          statusCode: 200
          body:                   # body uses Joi type definitions (https://github.com/hapijs/joi)
            resultCount: Joi.number().integer()
            results:
              - trackName: Joi.string()
                collectionName: Joi.string()

The file is also accepted in the equivalent JSON format. Supported file extensions are .yaml, .yml, and .json. You can also add .skipped to the contract file to skip executing it.

Contracts Directory

In order to prevent large, unwieldy contracts files becoming a necessity, it is possible to specify contracts for a single consumer across multiple files. This behaviour is only possible when using the Jackal client to communicate with the Jackal server - it is not possible to upload many files to the server in a single request.

Each file must follow the format illustrated above and must share a common consumer at the top level. Currently, these files are merged at consumer level, so if a provider is defined in multiple files then contracts defined for the same provider in a later file may overwrite those in an earlier one.

Sending the Contracts

Using the Jackal Client

Contracts can be sent to a Jackal server using the Jackal client by specifying the URL of the Jackal server and the path to the contracts file or directory:

jackal send <jackalUrl> <contractsPath>

By default, the results of sending contracts to a Jackal server using the client are displayed in spec format, for information on how to specify alternatives, please consult the Jackal Client Guide.

Using Curl

Contracts can also be sent to a Jackal server using curl (or similar), however only a single contracts file can be sent, sending a directory of files is not possible:

curl -X POST --silent http://jackal.url:25863/api/contracts -H 'Content-Type: application/json' -d @contracts.json

You should then receive a JSON object in response, for example:

{
  "message": "All Passed",
  "status": "PASSED",
  "results": [
    {
      "name": "itunes/search_by_term_and_country/OK",
      "consumer": "itunes_search_app",
      "status": "Pass",
      "error": null
    }
  ]
}

Testing Contracts as a Provider

Using the Jackal Client

Provider contracts stored on a Jackal server can be run using the Jackal client by specifying the URL of the Jackal server and the name of the provider for which contracts should be run:

jackal run <jackalUrl> <providerName>

By default, the results of running provider contracts on a Jackal server using the client are displayed in spec format, for information on how to specify alternatives, please consult the Jackal Client Guide.

Using Curl

Provider contracts stored on a Jackal server can also be run using curl (or similar):

curl -X GET --silent http://localhost:25863/api/contracts/PROVIDER_NAME -H 'Content-Type: application/json'

You should then receive a JSON object in response, for example:

{
  "message": "All Passed",
  "status": "PASSED",
  "results": [
    {
      "name": "itunes/search_by_term_and_country/OK",
      "consumer": "itunes_search_app",
      "status": "Pass",
      "error": null
    }
  ]
}

Sequence of Testing

This diagram illustrates the flow of our expected use case.