UNPKG

llm-emulator

Version:

Enterprise-grade LLM mock server for local and CI: scenarios, faults, latency, contracts, VCR. Supports standalone server and Express middleware.

29 lines (21 loc) 602 B
import { matchPathPattern } from "./matchPathPattern.js"; export function findHttpMock(httpMocks = [], req) { const method = req.method.toUpperCase(); const path = req.path || "/"; for (const mock of httpMocks) { const match = mock.match || {}; const wantMethod = (match.method || "").toUpperCase(); if (wantMethod && wantMethod !== method) { continue; } if (!match.path) { continue; } const result = matchPathPattern(match.path, path); if (!result) { continue; } return { mock, params: result.params || {} }; } return null; }