{"id":17536,"library":"cloudly-http","title":"Cloudly HTTP Request/Response Utility","description":"Cloudly HTTP is a TypeScript-first utility library designed to streamline the handling of HTTP requests and responses in JavaScript/TypeScript environments. Currently in its early stages (version 0.1.8), it aims to provide a structured and type-safe approach to building HTTP clients and servers, likely targeting serverless or cloud-native applications given the 'Cloudly' prefix. The library focuses on encapsulating HTTP logic, offering features like configurable client constructors and explicit path management. Its core differentiator lies in its strong TypeScript typing and structured API for managing complex HTTP interactions, rather than being a generic fetch wrapper, which helps prevent common runtime errors and improves code maintainability. It has a relatively rapid release cadence in its minor versions due to being in early development.","status":"active","version":"0.1.8","language":"javascript","source_language":"en","source_url":"https://github.com/utily/cloudly-http","tags":["javascript","typescript"],"install":[{"cmd":"npm install cloudly-http","lang":"bash","label":"npm"},{"cmd":"yarn add cloudly-http","lang":"bash","label":"yarn"},{"cmd":"pnpm add cloudly-http","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary class for making HTTP requests. Use named import for ESM. Direct CommonJS require is not supported without transpilation.","wrong":"const Client = require('cloudly-http')","symbol":"Client","correct":"import { Client } from 'cloudly-http'"},{"note":"Type definition for an HTTP request object. Important for type-checking when defining request handlers or interceptors.","symbol":"HttpRequest","correct":"import type { HttpRequest } from 'cloudly-http'"},{"note":"Type definition for an HTTP response object. Essential for ensuring type-safe handling of responses.","symbol":"HttpResponse","correct":"import type { HttpResponse } from 'cloudly-http'"},{"note":"Interface for the client constructor's configuration object, especially after the v0.1.0 breaking change to named callbacks.","symbol":"ClientConfig","correct":"import type { ClientConfig } from 'cloudly-http'"}],"quickstart":{"code":"import { Client, type HttpRequest, type HttpResponse, type ClientConfig } from 'cloudly-http';\n\ninterface MyAPIResponse {\n  message: string;\n  status: string;\n}\n\n// Define a mock fetch-like function for demonstration\nconst mockFetch = async (request: HttpRequest): Promise<HttpResponse> => {\n  console.log(`Mock Fetch: ${request.method} ${request.url}`);\n  if (request.url === '/api/hello') {\n    return {\n      status: 200,\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify({ message: 'Hello from Cloudly!', status: 'success' })\n    };\n  }\n  return {\n    status: 404,\n    headers: { 'Content-Type': 'application/json' },\n    body: JSON.stringify({ message: 'Not Found', status: 'error' })\n  };\n};\n\nconst clientConfig: ClientConfig = {\n  // In a real app, this would be a configured handler, e.g., for node-fetch or browser fetch\n  request: async (request: HttpRequest) => {\n    // Simulate network delay\n    await new Promise(resolve => setTimeout(resolve, 50));\n    return mockFetch(request);\n  }\n};\n\nconst apiClient = new Client(clientConfig);\n\nasync function fetchData() {\n  try {\n    const response = await apiClient.get<MyAPIResponse>('/api/hello');\n    if (response.status === 200 && response.body) {\n      const data = response.body;\n      console.log('Received data:', data.message);\n    } else {\n      console.error('API Error:', response.status, response.body);\n    }\n\n    const notFoundResponse = await apiClient.get('/api/unknown');\n    console.log('Not Found Response Status:', notFoundResponse.status);\n\n  } catch (error) {\n    console.error('Request failed:', error);\n  }\n}\n\nfetchData();\n","lang":"typescript","description":"This quickstart demonstrates how to instantiate the `Client` with a mock request handler, make a GET request, and process the typed response, highlighting the library's structured approach to HTTP interactions."},"warnings":[{"fix":"Refactor `new Client(callback1, callback2)` to `new Client({ request: callback1, response: callback2 })` or similar named properties as defined by the `ClientConfig` interface.","message":"The Client constructor no longer accepts positional arguments. Instead, it now requires a single object argument for its configuration, primarily for named callbacks.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Ensure all path strings begin with `/`. For example, change `client.get('users')` to `client.get('/users')`.","message":"All `path` parameters passed to client methods (e.g., `client.get(path)`) must now be explicitly prefixed with a forward slash (`/`).","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Monitor GitHub repository for updates, read release notes carefully, and consider pinning the exact package version in your `package.json` (e.g., `\"cloudly-http\": \"0.1.8\"`).","message":"As a library in early development (currently v0.1.x), Cloudly HTTP may introduce further breaking changes in minor or patch versions. Developers should pin exact versions or review changelogs diligently.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Update the Client constructor to use a configuration object: `new Client({ request: myRequestHandlerFunction })`.","cause":"Attempting to use `client.get('path')` without correctly initializing the Client constructor with named callbacks after the v0.1.0 breaking change.","error":"TypeError: Cannot read properties of undefined (reading 'get')"},{"fix":"Prefix the path with a forward slash: `client.get('/users')` instead of `client.get('users')`.","cause":"The `path` parameter for client methods (e.g., `get`, `post`) is missing the mandatory leading forward slash (`/`) introduced in v0.1.0.","error":"UnhandledPromiseRejection: Error: Invalid path: 'users' (missing leading slash)"},{"fix":"Ensure the `Client` constructor receives an object that conforms to the `ClientConfig` interface, e.g., `new Client({ request: myRequestCallback })`.","cause":"Passing a non-object argument to the `Client` constructor when `ClientConfig` (an object with named callbacks) is expected.","error":"TS2345: Argument of type 'string' is not assignable to parameter of type 'ClientConfig'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}