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

api-contracts

v0.2.0

Published

Suite of utilities for working with the API Contracts testing model.

Downloads

1

Readme

api-contracts

Table of contents

Introduction

We'd like to introduce a strategy for keeping your applications [communication layer, apis, etc..] in sync. The pattern we'll be talking about is based on Consumer Driven Contracts.

The primary actors involved are the consumer and the producer:

  • Consumer  — defines and publishes a contract using JSON Schema
  • Producer — imports and satisfies a contract

The Problem

Everyone today has responsibility over applications that consume multiple APIs. Trouble arises when you'd like to make a change to an API without breaking other consumers.

People use tools like API Blueprint or slacker or tests within the API's code itself to specify the requirements for an API. However, these tools and strategies do not account for the consuming applications that may break. You can change a test with the APIs codebase and not know whether you've broken any given consumer.

Our strategy reverses this paradigm. When we allow the consumer to specify the requirements for an API (or producer), we can make changes to an producer and know immediately which consumers are compatible with that change. ~~Additionally, we know when a version of an API can be retired, because we know when there are no more consumers of that API.~~

How it Works

The consumer maintains the contract for a given producer.

  1. The producer requires the contract, at a very specific version, from the consumer from an npm package.
  2. The producer tests its API against the contract from the consumer.
  3. If the contract tests fail, it means the contracts and the consumer application need to be updated to ensure that the consumer continues to work as expected.

For example

Your client is a consumer app that defines the contract for its producer app: The API server.

The client consumes the API

Changes to server (or producer) responses can potentially break the client (or consumer) without API developers knowing about the breaking changes. To prevent this, the consumer publishes a contract that it expects the API to satisfy. When the producer runs tests it verifies its responses will satisfy the consumer’s needs. If the responses don’t satisfy the consumer's needs, we know that the consumer won’t work as expected, after the changes are published.