
Security News
/Company News
Socket Is Sponsoring Composer and Packagist
Socket has joined the new Composer and Packagist sponsorship program as a launch sponsor, supporting the team that keeps PHP's package ecosystem secure.
A lightweight, flexible HTTP client library with request interception, automatic retry, and logging capabilities, designed for modern web applications.
A lightweight, flexible HTTP client library with request interception, automatic retry, and logging capabilities, designed for modern web applications.
npm install reqforge
const { request, interceptor } = require('reqforge');
// Add a request interceptor
const reqInterceptor = interceptor.createRequestInterceptor();
reqInterceptor.use((config) => {
console.log('Request:', config.url);
return config;
});
// Make a request
request.get('/users')
.then(res => res.json())
.then(data => console.log(data));
See the examples directory for more usage examples:
The request module provides:
sendRequest(endpoint, data, options) - Generic request methodget(endpoint, options) - GET requestpost(endpoint, data, options) - POST requestput(endpoint, data, options) - PUT requestdel(endpoint, options) - DELETE requestThe config module provides:
getBaseURL() - Get the base URL for API requestsAPI_VERSION - Current API versiondefaultConfig - Default configuration objectmergeConfig(customConfig) - Merge custom configuration with defaultsThe DebugLogger class provides:
log(message) - Log a messageinfo(message) - Log an info messagewarn(message) - Log a warning messageerror(message) - Log an error messagedebug(message, data) - Log debug message with optional data (only when debug mode enabled)enableDebug() - Enable debug modeThe auth module provides:
login(username, password) - Login and store tokenlogout() - Logout and clear tokengetToken() - Get current auth tokensetToken(token) - Set auth token manuallyisAuthenticated() - Check if authenticatedThe errors module provides:
ReqForgeError - Base error classNetworkError - Network request failuresTimeoutError - Request timeout errorsAuthError - Authentication failuresValidationError - Validation errorsErrorCodes - Error code constantscreateErrorFromResponse(response) - Create error from HTTP responseThe retry module provides:
withRetry(fn, options) - Execute function with automatic retrycalculateBackoff(attempt, baseDelay, maxDelay) - Calculate exponential backoff delayOptions for withRetry:
maxRetries (default: 3) - Maximum number of retry attemptsdelay (default: 1000) - Initial delay in millisecondsbackoff (default: 2) - Backoff multipliershouldRetry(error) - Function to determine if retry should occurThe interceptor module provides request and response interception:
createRequestInterceptor() - Create request interceptor managercreateResponseInterceptor() - Create response interceptor manageruse(fulfilled, rejected) - Add interceptor handlereject(id) - Remove interceptor handlerclear() - Clear all handlersforEach(data) - Process data through all handlersThe cache module provides:
MemoryCache - In-memory cache with TTL support
get(key) - Get cached valueset(key, value, ttl) - Set cached value with optional TTLhas(key) - Check if key existsdelete(key) - Remove cached entryclear() - Clear all entriessize() - Get cache sizecreateCacheKey(url, params) - Generate cache key from URL and paramsThe utils module provides:
buildURL(baseURL, params) - Build URL with query parametersserializeQuery(obj) - Serialize object to query stringparseQuery(queryString) - Parse query string to objectdeepMerge(target, source) - Deep merge objectsisPlainObject(value) - Check if value is a plain objectdelay(ms) - Delay executionTypeScript type definitions are included. Import types:
import { request, config, Logger } from 'reqforge';
npm test
See CHANGELOG.md for version history.
MIT
FAQs
A lightweight, flexible HTTP client library with request interception, automatic retry, and logging capabilities, designed for modern web applications.
The npm package reqforge receives a total of 32 weekly downloads. As such, reqforge popularity was classified as not popular.
We found that reqforge demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Company News
Socket has joined the new Composer and Packagist sponsorship program as a launch sponsor, supporting the team that keeps PHP's package ecosystem secure.

Research
/Security News
Benign-looking npm packages split malicious functionality across a dependency chain that deploys a cross-platform RAT targeting Alibaba developers.

Research
/Security News
Two Joyfill npm beta releases contain an import-time implant that uses blockchain transactions to retrieve a remote-access trojan.