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

serverless-offline-pact

v0.0.5

Published

Serverless Framework Plugin to download and run a pact stub service

Downloads

14

Readme

serverless-offline-pact

David GitHub code size in bytes GitHub repo size npm npm npm npm NPM npm GitHub last commit npm collaborators

Serverless Framework Plugin to download and run a pact stub service with a user provided pact file

Installation

To install with npm, run this in your service directory:

npm install --save-dev serverless-offline-pact

or yarn

yarn add serverless-offline-pact --dev

Then add this to your serverless.yml

plugins:
  - serverless-offline-pact

How it works

The plugin downloads the official pact standalone on Your Computer and allows the serverless-offline app to launch it.

Configuration

To configure pact Offline, add a pact section like this to your serverless.yml:


plugins:
  - serverless-offline-pact

custom:
  pact:
    stub:
      stages: # Enables stub, based on stage parameter
        - dev
      filePath: 'pact.json'

See ./examples/minimal/serverless.yml

You can run yarn install && yarn test:all to see it in action

The above is the minimal set of options, the full options are below

custom:
  pact:
    stub:
      stages: # Enables stub, based on stage parameter
        - dev
      filePath: 'pact.json' # URI if broker params provided
      port: '9999' # Port on which to run the service
      host: 'localhost' # Host on which to bind the service Default: localhost
      logLevel: 'DEBUG' # Log level. Options are DEBUG INFO WARN ERROR Default: DEBUG
      brokerUsername: '' # Pact Broker basic auth username
      brokerPassword: '' # Pact Broker basic auth password
      brokerToken: '' # Pact Broker bearer token (can also be set using the PACT_BROKER_TOKEN environment variable)
      cors: true # Support browser security in tests by responding to OPTIONS requests and adding CORS headers to mocked responses
      ssl: false # Use a self-signed SSL cert to run the service over HTTPS
      sslCertPath: '' # Specify the path to the SSL cert to use when running the service over HTTPS
      sslKeyPath: '' # Specify the path to the SSL key to use when running the service over HTTPS
      noStart: true # Does not start pact. This option is useful if you already have a running instance of pact locally

See the ./examples/full/serverless.yml for a working serverless project as an example

You can run yarn install && yarn test:all to see it in action

Pact Stub Service Features

  • Start a stub service with the given pact file(s) or directories.
  • Pact URIs may be local file or directory paths, or HTTP.
  • Include any basic auth details in the URL using the format https://USERNAME:PASSWORD@URI.
  • Where multiple matching interactions are found, the interactions will be sorted by response status, and the first one will be returned.
  • This may lead to some non-deterministic behaviour. If you are having problems with this, please raise it on the pact slack channel.
  • Note that only versions 1 and 2 of the pact specification are currently fully supported.
  • Pacts using the v3 format may be used, however, any matching features added in v3 will currently be ignored.

TODO

  • Tests
  • Detect operating system and download corresponding binary currently downloads macosx, need to support linux 32/64bit and windows