Code Salmon Documentation

A TypeScript backend dev's most trusted gadget against the dastardly silent assassins known only as REST API Contract Drift.

What is Code Salmon?

Code Salmon is a CLI tool that scans TypeScript projects for REST API calls. Once identified, it fires those calls to create a baseline JSON snapshot for future comparisons—your bulletproof vest against silent API drift.

  • Scan your project's REST API calls
  • Compare results to your original baseline
  • Adjust code to reflect any API changes

Problem Solved

External APIs evolve. When they do, your application might silently break. Code Salmon stops that by:

  • Detecting contract drift early
  • Tracking every endpoint you depend on

Features

  • Scans .ts files for fetch() calls
  • Extracts API URLs and environment keys
  • Fetches and saves baseline responses in JSON
  • Compares future responses to detect structural drift
  • Reports drift directly in the terminal

Configuration Tips

  • Ensure a valid .env file exists with relevant API keys
  • Customize scan targets via tsconfig.json

Installation & Usage

npm install codesalmon

To generate your initial baseline:

scanSalmon

To check for contract drift later:

swimSalmon

*Pro Tip: For meaningful contract drift, wait days or weeks between scans to observe real API changes.*

Contract Drift Report

When you run swimSalmon, the CLI outputs a detailed report highlighting any changes to API responses.

Possible Report Outputs

  • Changed at: Indicates fields with value/type changes
  • Addition at: Shows where new key/value pairs were added
  • Removed at: Flags missing fields from the original baseline
  • Unhandled Change Type: Catches unknown or deeply restructured responses