Skip to content

Repository files navigation

Solvix Logo

Solvix

Enterprise-Grade HTTP Orchestration Engine for Modern JavaScript

Resilience β€’ Security β€’ Observability β€’ Control

npm version license typescript support node version security bundle size tests


Solvix is an HTTP orchestration engine β€” not just a client. It transforms simple API requests into secure, observable, resilient, and fully controlled execution pipelines.

Unlike traditional HTTP clients (Axios, Got, SuperAgent) that leave resilience, security, and observability to the developer, Solvix bakes ~50 features into a single 33 KB package.


Why Solvix?

Feature Solvix Axios Got
Security (CRLF protection, size guards, method allowlisting, HTTPS enforcement, header sanitization) βœ… 12 features ❌ Cookie/XSS only ❌ Basic
Circuit Breaker βœ… Built-in ❌ ❌
Rate Limiter (token bucket + adaptive from headers) βœ… Built-in ❌ ❌
Request Deduplication βœ… Built-in ❌ ❌
Priority Queue with concurrency control βœ… Built-in ❌ ❌
SSE / JSON Lines streaming βœ… Built-in ❌ ❌
W3C Distributed Tracing βœ… Built-in ❌ ❌
Health Checks βœ… Built-in ❌ ❌
Correlation IDs βœ… Built-in ❌ ❌
Structured Logging βœ… Built-in ❌ ❌
Metrics (counters + histograms) βœ… Built-in ❌ ❌
Request Timeline & Profiling βœ… Built-in ❌ ❌
Snapshot Debugging βœ… Built-in ❌ ❌
Shadow Mode (dual API testing) βœ… Built-in ❌ ❌
Offline Queue βœ… Built-in ❌ ❌
Token Refresh (stampede-safe) βœ… Built-in ❌ ❌
CSRF Protection βœ… Built-in ❌ ❌
Cookie Jar βœ… Built-in ❌ ❌
ETag / Conditional Requests βœ… Built-in ❌ ❌
Fallback URLs βœ… Built-in ❌ ❌
Upload/Download Progress βœ… Built-in βœ… βœ…
Custom Middleware βœ… client.use() βœ… Interceptors ❌
SSL/TLS Customization βœ… (via undici) βœ… βœ…
HTTP Proxy βœ… (via undici) βœ… βœ…
Bundle Size 33 KB ~52 KB ~42 KB

Quick Start

npm install @adityadev13/solvix
import { createClient } from "@adityadev13/solvix";

const api = createClient({ baseURL: "https://api.example.com" });

const res = await api.get("/users");
console.log(res.data);        // parsed JSON
console.log(res.status);      // 200
console.log(res.meta);        // timing, timeline, profiling

Core Features

πŸ›‘οΈ Security

const api = createClient({
  security: {
    enforceHTTPS: true,
    allowedDomains: ["api.example.com"],
    allowedMethods: ["GET", "POST"],
    maxBodySize: 1_000_000,
    maxResponseSize: 10_000_000,
  },
  csrf: { enabled: true },               // Auto-inject CSRF token from cookie
  tls: { rejectUnauthorized: false },     // Self-signed certs (Node.js)
  proxy: { host: "gateway.corp.com", port: 8080 }, // Corporate proxy
});
  • CRLF injection protection (always on)
  • Forbidden header stripping (Host, Connection, Content-Length)
  • Insecure header stripping (Authorization, Cookie, X-Api-Key)
  • Snapshot redaction (passwords masked in debug output)
  • Domain whitelisting, method allowlisting, size guards

⚑ Resilience

const api = createClient({
  retry: { retries: 3, factor: 2, jitter: true },
  circuitBreaker: { failureThreshold: 5, rollingWindow: 10000 },
  rateLimit: { capacity: 10, refillRate: 5, interval: 1000 },
  dedupe: true,                           // 1000 identical calls β†’ 1 network request
  fallbackURLs: ["https://backup.example.com"],
  maxConcurrency: 50,
});
  • Retry with exponential backoff, jitter, and adaptive timing
  • Circuit breaker per-host with half-open probes
  • Token bucket rate limiter with server-side header sync
  • Priority queue with concurrency control and drop strategies
  • Automatic deduplication via SHA-256 fingerprinting

πŸ” Observability

const api = createClient({
  timeline: { enabled: true },
  profiling: { enabled: true },
  correlation: { enabled: true },
  tracing: { enabled: true },
  logger: console,
  metrics: { enabled: true },
  healthCheck: { enabled: true, endpoint: "/health" },
});

// Events β€” subscribe globally
import { SolvixBus } from "@adityadev13/solvix";
SolvixBus.on("request:complete", (e) => {
  console.log(`${e.context.url} β†’ ${e.context.response?.status}`);
});

// Metrics β€” aggregate counters
const m = api.metrics();
console.log(m.totalRequests, m.successCount, m.failureCount, m.durationHistogram);

// Health β€” check backend status
console.log(api.healthCheck?.isHealthy());
  • 15-stage request timeline with microsecond precision
  • Profile metrics: queue wait, rate limit wait, network, parse, total time
  • W3C traceparent header for distributed tracing
  • Correlation IDs (X-Request-ID) in every log line
  • Duration histogram with configurable buckets
  • Periodic health endpoint pinging with status change callbacks

πŸ“¦ Data Handling

// Streaming (SSE / JSON Lines)
for await (const event of api.get("/events", { sse: true })) {
  console.log(event.data);
}

// Upload progress
const api = createClient({
  hooks: {
    onUploadProgress: ({ loaded, total }) => console.log(`${loaded}/${total}`),
    onDownloadProgress: ({ percent }) => updateProgressBar(percent ?? 0),
  },
});

// Custom response validation
const api = createClient({
  validateResponse: (data) => {
    if (!data.id) throw new Error("Missing id");
    return data as MyType;
  },
});

// Custom params format
const api = createClient({
  paramsSerializer: (params) =>
    `https://api.example.com/search?${Object.entries(params).map(([k, v]) => `${k}[]=${v}`).join("&")}`,
});
  • Body types: json, form, multipart, text, blob, arrayBuffer, raw
  • Response types: json, text, blob, arrayBuffer, formData, stream, raw
  • Transform pipeline: transformRequest β†’ buildRequestBody β†’ transport β†’ parseResponse β†’ transformResponse β†’ validateResponse
  • SSE parsing, JSON Lines (NDJSON), raw stream iteration
  • Upload/download progress via ReadableStream counting

πŸ”„ Middleware

const api = createClient({ baseURL: "https://api.example.com" });

api.use(async (ctx, next) => {
  const start = Date.now();
  await next();
  console.log(`${ctx.url} took ${Date.now() - start}ms`);
});

Custom middleware runs in the request pipeline before the transport layer. Compose multiple middleware in order (onion model).


Architecture

Every request flows through a controlled pipeline:

Security Checks β†’ Query Params β†’ Fingerprinting β†’ Dedup/Cache Check
β†’ Dependency Wait β†’ Priority Queue β†’ Rate Limiter β†’ Circuit Breaker
β†’ Retry Loop (sanitize β†’ build body β†’ middleware stack β†’ parse)
β†’ Validation β†’ Caching β†’ Events β†’ Logging β†’ Response

All stages are opt-in. Nothing runs unless configured.


Documentation

For full documentation, API reference, and advanced guides:

  • Detailed Docs β€” solvix-client.github.io/solvix-docs
  • API Reference β€” Full JSDoc available in-editor via TypeScript declarations
  • Benchmarks β€” Run npm run bench:all locally to see performance on your hardware

Supported Runtimes

  • Node.js 18+
  • Modern browsers (Chrome, Firefox, Safari, Edge)
  • Deno, Bun
  • Edge runtimes (Cloudflare Workers, Vercel Edge)

Installation

npm install @adityadev13/solvix
pnpm add @adityadev13/solvix
yarn add @adityadev13/solvix
bun add @adityadev13/solvix

License

MIT


Contributing

We welcome feature proposals, bug reports, security reviews, and performance improvements.

Solvix transforms API communication into a reliable, observable, secure, and orchestrated execution system. It is not just a client β€” it is infrastructure.

❀️ Sponsor

If Solvix has helped you build better applications, please consider supporting its development.

Your sponsorship helps fund:

  • πŸš€ New features
  • πŸ› Bug fixes
  • πŸ“š Documentation
  • ⚑ Performance improvements
  • πŸ§ͺ Testing & CI
  • πŸ”’ Long-term maintenance

πŸ‘‰ Sponsor Solvix: Buy Me a Coffee

Every contribution helps keep Solvix free and open source.

About

A transport-agnostic, extensible HTTP client with built-in resilience and observability.

Topics

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages