Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:APIJSON APIJSON Demo Server JS

From Leeroopedia
Knowledge Sources
Domains Testing, HTTP_Server, Node_JS
Last Updated 2026-10-14 00:00 GMT

Overview

Concrete tool for running a Koa HTTP server that triggers and monitors APIJSON regression tests, comparing responses against standards.

Description

The Server.js module is a Koa-based HTTP server (port 3000) that exposes endpoints for automated APIJSON regression testing: /test/start (launches App.autoTest), /test/status (returns progress and report link), /test/compare (compares a response against a standard via JSONResponse.compareResponse), and /test/ml (ML-mode comparison). It handles CORS, tracks progress across accounts, test cases, deep tests, and random tests.

Usage

Run this Node.js server when you need to execute APIJSON regression tests from a headless environment and query test progress via HTTP.

Code Reference

Source Location

Signature

const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const {getRequestFromURL, App} = require('./main');
const JSONResponse = require('../apijson/JSONResponse');

// Endpoints:
// /test/start  - Launch auto testing
// /test/status - Query progress
// /test/compare - Compare response vs standard
// /test/ml     - ML-mode comparison
app.listen(PORT);  // PORT = 3000

Import

node server.js

I/O Contract

Inputs

Name Type Required Description
key String No Test query parameter for elevated test counts
response JSONObject No Actual response for comparison
standard JSONObject No Expected standard for comparison

Outputs

Name Type Description
/test/status returns JSONObject Progress, message, reportId, link
/test/compare returns JSONObject Diff comparison result

Usage Examples

Start Regression Test

# Start auto testing
curl http://localhost:3000/test/start

# Check status
curl http://localhost:3000/test/status
# {"code":200,"msg":"Auto testing...","progress":0.5,...}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment