@yxcinebendjebbar/asdc
v0.0.6
Published
A zero-dependency, OOP HTTP/WebSocket/RPC client designed to be ported cleanly to other languages
Maintainers
Readme
@yxcinebendjebbar/asdc
Zero-dependency, OOP HTTP / WebSocket / JSON-RPC client for TypeScript, built with native fetch and WebSocket only.
Architecture is deliberately language-agnostic (Strategy, Chain of Responsibility, Adapter) so the same design ports to Go / Python later.
Usage
import { HttpClient } from './src';
const api = new HttpClient({ baseURL: 'https://api.example.com', timeout: 5000 });
api.interceptors.request.use((config) => {
config.headers = { ...config.headers, Authorization: 'Bearer token' };
return config;
});
const { data } = await api.get('/users/1');import { WebSocketClient, JsonRpcClient } from './src';
const ws = new WebSocketClient('wss://api.example.com/ws');
ws.connect();
const rpc = new JsonRpcClient(ws);
const result = await rpc.call('getUser', { id: 1 });Structure
src/
core/ RequestConfig, Response, errors, InterceptorManager (Chain of Responsibility)
transport/ Transport interface (Strategy) + FetchTransport
http/ HttpClient (axios-style API)
ws/ WebSocketClient (native WS + backoff reconnect)
rpc/ JsonRpcClient (JSON-RPC 2.0, Adapter over HTTP or WS)
utils/ QueryString helpersRoadmap
- Node
http/httpstransport (nofetchdependency for older runtimes) - GraphQL client (Adapter over
HttpClient, same interceptor pipeline) - Retry policy plugin (Strategy, composes with
Transport)
