{"id":15819,"library":"scoped-http-client","title":"Scoped HTTP Client for Node.js","description":"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.","status":"abandoned","version":"0.11.0","language":"javascript","source_language":"en","source_url":"https://github.com/technoweenie/node-scoped-http-client","tags":["javascript"],"install":[{"cmd":"npm install scoped-http-client","lang":"bash","label":"npm"},{"cmd":"yarn add scoped-http-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add scoped-http-client","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package uses CommonJS `require()` syntax; ESM `import` is not supported.","wrong":"import scopedClient from 'scoped-http-client';","symbol":"scopedClient","correct":"const scopedClient = require('scoped-http-client');"},{"note":"The `create` method is accessed via the default export of the module. While `require().create` works, assigning the module export first is conventional.","wrong":"const client = require('scoped-http-client').create('https://api.example.com');","symbol":"create","correct":"const client = scopedClient.create('https://api.example.com');"},{"note":"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.","wrong":"client.get(callback); // Missing () to execute the request builder","symbol":"Client Methods (.get, .post, .header, .path)","correct":"client.header('Accept', 'application/json').get()(callback);"}],"quickstart":{"code":"const scopedClient = require('scoped-http-client');\nconst util = require('util'); // Node.js built-in module\n\n// Example 1: Basic GET request\nconst githubClient = scopedClient.create('https://api.github.com')\n  .header('accept', 'application/json')\n  .path('users/technoweenie')\n  .get()(function(err, resp, body) {\n    if (err) {\n      console.error('Error fetching user:', err);\n      return;\n    }\n    console.log('GET Response Status:', resp.statusCode);\n    util.puts('User Info: ' + body);\n  });\n\n// Example 2: POST request within a scope\nconst token = process.env.GITHUB_TOKEN ?? 'YOUR_DUMMY_GITHUB_TOKEN'; // Replace with a real token or handle auth\nconst scopedBaseClient = scopedClient.create('https://api.github.com')\n  .query({ token: token });\n\nscopedBaseClient.scope('user/repos', function(cli) {\n  const data = JSON.stringify({ name: 'my-new-repo', description: 'A test repository' });\n  cli.post(data)(function(err, resp, body) {\n    if (err) {\n      console.error('Error creating repo:', err);\n      return;\n    }\n    console.log('POST Response Status:', resp.statusCode);\n    util.puts('Repo creation response: ' + body);\n  });\n});","lang":"javascript","description":"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."},"warnings":[{"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.","message":"This 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.","severity":"breaking","affected_versions":">=0.11.0"},{"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).","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Avoid using this package in new projects. For existing projects, prioritize migration to a secure, actively maintained alternative.","message":"The 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Replace `util.puts()` with `console.log()` for output in modern Node.js applications.","message":"The `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.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Consider alternatives like `axios` or `got` for projects requiring robust HTTP client features.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Run `npm install scoped-http-client` in your project directory.","cause":"The package has not been installed or is not correctly listed in `package.json`.","error":"Error: Cannot find module 'scoped-http-client'"},{"fix":"Ensure the HTTP method call is immediately invoked to trigger the request, e.g., `client.get()(function(err, resp, body){...})`.","cause":"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()`.","error":"TypeError: client.get is not a function"},{"fix":"Verify the target URL, port, and ensure the server is running and accessible from the client's environment.","cause":"The client could not establish a connection to the target server, often due to the server being offline, incorrect host/port, or firewall issues.","error":"Error: connect ECONNREFUSED <IP_ADDRESS>:<PORT>"}],"ecosystem":"npm"}