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

contract-proxy

v1.0.1

Published

API Contract Validation Tool

Downloads

104

Readme

ContractTesting

ContractTesting is a framework designed to streamline contract testing in a microservices architecture. In distributed systems, where multiple services communicate, it’s critical to ensure consistent and predictable interactions as services evolve independently. This framework helps validate that the communication between services remains stable, ensuring that the consumer-provider agreements (contracts) are upheld.

Features

  • Microservices Contract Validation: Ensure services continue to communicate according to agreed-upon contracts (e.g., API specifications).
  • OpenAPI Contract Testing: Validate service interactions using OpenAPI specifications to ensure adherence to the expected data formats and communication protocols.
  • Prism Framework Integration: Leverage Prism, a powerful tool for contract testing, to simulate and validate provider responses against consumer expectations.

Why Contract Testing?

In a microservices architecture, independent service evolution can lead to broken integrations if service interfaces change unexpectedly. Contract testing mitigates this by ensuring:

  • Services (providers) adhere to contracts defined by the consumer.
  • Early detection of breaking changes in services.
  • Increased confidence in the reliability of your system’s inter-service communication.

How It Works

  1. Consumer-Driven Contracts: The consumer service defines the expectations in the form of contracts (API specifications), such as an OpenAPI document.
  2. Provider Validation: Using the Prism framework, the provider’s responses are validated against the predefined contract.
  3. Test Automation: Integrate into CI/CD pipelines for continuous contract verification and instant feedback on breaking changes.

Getting Started

  1. Clone the Repository:

    git clone https://github.com/dipjyotimetia/ContractTesting.git
    cd ContractTesting
  2. Install Dependencies: Ensure you have Node.js installed, then run:

    npm install
  3. Run Contract Tests: You can start running your contract tests with:

    npm run test:contract
  4. Prism Integration: Prism can be used to mock and validate API interactions. Follow the Prism documentation for advanced setup and usage.

Example Use Case

For a consumer service that expects a specific API response format from a provider, this framework will:

  • Define the API contract using OpenAPI.
  • Run contract tests using Prism to ensure the provider complies with the API contract.
  • Provide immediate feedback on any contract violations.

CI/CD Integration

Add contract tests to your CI/CD pipelines to continuously verify that your microservices' interactions remain valid as services evolve:

# Example GitHub Actions workflow
name: Contract Testing
on:
  push:
    branches:
      - main
jobs:
  contract-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Install dependencies
        run: npm install
      - name: Run contract tests
        run: npm run test:contract