Registry / http-networking / scoped-http-client

scoped-http-client

JSON →
library0.11.0jsnpmunverified

Scoped HTTP Client provides a fluent, chainable API wrapper around Node.js's native `http` client, simplifying common HTTP request patterns. Instead of handling numerous optional arguments directly on `http.request`, it allows developers to build requests by chaining methods like `.header()`, `.path()`, `.query()`, and `.get()`/`.post()`. A key feature is its 'scoping' mechanism, enabling temporary modifications to client parameters for specific requests without altering the base client instance. The package's current stable version is 0.11.0, last published in 2015. Given its age and an `engines` declaration targeting `node >= 0.8.0`, it is no longer actively maintained and is likely incompatible with modern Node.js environments. Its approach to request building has largely been superseded by contemporary HTTP clients like Axios, Got, or the native Fetch API, which offer more robust features, Promises/async-await support, and active maintenance.

npm install scoped-http-client
INSTALL
IMPORT
SIG · SCOPED-HTTP-CLIENT
S
scoped-http-client
http-networkingjavascriptv0.11.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

scopedClient
const scopedClient = require('scoped-http-client');
import scopedClient from 'scoped-http-client';
This package uses CommonJS `require()` syntax; ESM `import` is not supported.
create
const client = scopedClient.create('https://api.example.com');
const client = require('scoped-http-client').create('https://api.example.com');
The `create` method is accessed via the default export of the module. While `require().create` works, assigning the module export first is conventional.
Client Methods (.get, .post, .header, .path)
client.header('Accept', 'application/json').get()(callback);
client.get(callback); // Missing () to execute the request builder
HTTP method calls like `.get()` or `.post()` return a function that must be immediately invoked with `()` to execute the request, passing the callback to the invoked function.

Demonstrates creating a client, chaining methods for headers and paths, executing a GET request, and making a POST request within a scoped context, including basic error handling.

const scopedClient = require('scoped-http-client'); const util = require('util'); // Node.js built-in module // Example 1: Basic GET request const githubClient = scopedClient.create('https://api.github.com') .header('accept', 'application/json') .path('users/technoweenie') .get()(function(err, resp, body) { if (err) { console.error('Error fetching user:', err); return; } console.log('GET Response Status:', resp.statusCode); util.puts('User Info: ' + body); }); // Example 2: POST request within a scope const token = process.env.GITHUB_TOKEN ?? 'YOUR_DUMMY_GITHUB_TOKEN'; // Replace with a real token or handle auth const scopedBaseClient = scopedClient.create('https://api.github.com') .query({ token: token }); scopedBaseClient.scope('user/repos', function(cli) { const data = JSON.stringify({ name: 'my-new-repo', description: 'A test repository' }); cli.post(data)(function(err, resp, body) { if (err) { console.error('Error creating repo:', err); return; } console.log('POST Response Status:', resp.statusCode); util.puts('Repo creation response: ' + body); }); });
Debug
Known issues
breakingThis package targets Node.js version 0.8.0 and has not been updated since 2015. It is highly probable that it is incompatible with modern Node.js runtimes (e.js., Node.js v10+), especially due to changes in Node.js's internal `http` module and removal of deprecated APIs like `http.createClient` in Node.js v0.10.0.
fix
Migrate to a actively maintained HTTP client library such as `axios`, `node-fetch`, `got`, or the native `fetch` API available in recent Node.js versions.
affects: >=0.11.0
gotchaThe API is entirely callback-based, meaning it does not support Promises, `async/await`, or modern error handling patterns. This can lead to callback hell and make integration with contemporary JavaScript codebases challenging.
fix
Refactor logic to use modern Promise-based HTTP clients or wrap `scoped-http-client` calls in custom Promise functions (though this is not recommended due to the package's abandonment).
affects: >=0.1.0
gotchaThe package is unmaintained, meaning it will not receive updates for security vulnerabilities, bug fixes, or performance improvements. Using abandoned libraries can introduce significant security risks into an application's dependency tree.
fix
Avoid using this package in new projects. For existing projects, prioritize migration to a secure, actively maintained alternative.
affects: >=0.1.0
deprecatedThe `util.puts` function, used in the quickstart and README examples, is a deprecated Node.js API. It behaves similarly to `console.log` but with some historical differences in output buffering and newline handling.
fix
Replace `util.puts()` with `console.log()` for output in modern Node.js applications.
affects: >=0.1.0
gotchaThis client lacks advanced features common in modern HTTP libraries, such as automatic JSON parsing, request retries, rate limiting, interceptors, or comprehensive timeout configurations, making it less suitable for complex or resilient applications.
fix
Consider alternatives like `axios` or `got` for projects requiring robust HTTP client features.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'scoped-http-client'
The package has not been installed or is not correctly listed in `package.json`.
fix
Run `npm install scoped-http-client` in your project directory.
TypeError: client.get is not a function
This error likely means `client.get()` was called without the final `()` to execute the request builder, or `client` was not correctly initialized from `scopedClient.create()`.
fix
Ensure the HTTP method call is immediately invoked to trigger the request, e.g., `client.get()(function(err, resp, body){...})`.
Error: connect ECONNREFUSED <IP_ADDRESS>:<PORT>
The client could not establish a connection to the target server, often due to the server being offline, incorrect host/port, or firewall issues.
fix
Verify the target URL, port, and ensure the server is running and accessible from the client's environment.
Upgrade
Version history
0.11.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
scoped-http-client — npm install scoped-http-client · libregistry