Registry / http-networking / nyro
library0.1.3jsnpmunverified

Nyro is a promise-based HTTP and HTTP/2 request library for JavaScript and TypeScript, currently stable at version 2.0.4. It offers comprehensive support for all HTTP methods and focuses on performance and flexibility, incorporating features like proxy support, request queueing, caching mechanisms, and built-in pagination APIs. The library provides robust error handling, retries, and configurable timeouts. While it ships with TypeScript types, it is primarily designed for Node.js environments. Its "browser support" refers to browser-like features within Node rather than client-side browser usage. The project appears actively maintained with recent updates and differentiates itself by providing advanced functionalities such as `bodySchema` for response validation and specialized proxy tools.

npm install nyro
INSTALL
IMPORT
SIG · NYRO
N
nyro
http-networkingjavascriptv0.1.3
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.

nyro
import nyro from 'nyro';
const nyro = require('nyro');
Nyro is primarily an ESM module, direct CommonJS `require` can cause issues. Use dynamic import for CJS if necessary.
Method
import { Method } from 'nyro';
import nyro, { Method } from 'nyro';
Named export for HTTP methods enum. Also available as a string literal, e.g., 'GET'.
ResponseType
import { ResponseType } from 'nyro';
import * as NyroTypes from 'nyro';
Named export for expected response type enum (e.g., 'json', 'text').
NyroResponse
import type { NyroResponse } from 'nyro';
Type import for the response object, useful for TypeScript applications to define the shape of the `await nyro(...)` result.

Demonstrates a basic promise-based GET request, including URL parameters, HTTP method, expected response type, custom headers, and response body schema validation using Nyro. It logs the status code and the parsed AI reply.

import nyro, { ResponseType, Method } from 'nyro'; (async() => { const { body, statusCode } = await nyro({ url: 'https://hercai.onrender.com/v3/hercai', params: { question: 'Hi How Are You?' }, method: Method.Get, // Or 'GET' responseType: ResponseType.Json, // Or 'json' headers: { 'User-Agent': 'Nyro-App/1.0' }, bodySchema: { content: String, reply: String } }); console.log(`Status Code: ${statusCode}`); console.log('Your Question; ' + body.content); console.log('AI Reply; ' + body.reply); })();
Debug
Known issues
breakingVersion 2.0.0 introduced significant changes, likely transitioning to an ESM-first architecture. This means direct `require()` statements in CommonJS modules might no longer work as expected and may require configuration changes or dynamic imports.
fix
Migrate to ES module import syntax (`import ... from 'nyro';`) or use dynamic `import()` within CommonJS modules. Ensure your project's `package.json` specifies `"type": "module"` if it's an ESM project.
affects: >=2.0.0
gotchaThe documentation mentions 'Browser Support (Node Only)'. This implies that certain browser-like features or configurations are available when running Nyro in a Node.js environment, but the library is not intended for direct client-side browser usage.
fix
Do not attempt to use Nyro directly in a web browser. It is designed for server-side (Node.js) applications. For client-side, consider browser-native `fetch` or a dedicated browser-compatible HTTP client.
affects: >=1.0.0
gotchaThe `bodySchema` option is for defining the *expected structure* of the request body for validation and type safety, not for defining the actual data payload to be sent. Incorrectly assuming it's the request body itself can lead to empty or malformed requests.
fix
The actual data payload should be passed via the `body` option. Use `bodySchema` purely for validation against a JavaScript type constructor (e.g., `String`, `Number`, `Object`, `Array`) or custom validation functions.
affects: >=1.0.0
gotchaNyro includes a 'Layer7 Attack' feature. While potentially intended for security testing or load generation, using this functionality for malicious purposes is explicitly prohibited by the library's license and can lead to legal consequences.
fix
Exercise extreme caution and ensure legal and ethical compliance when using any features that could be construed as attack-oriented. Only use such features in controlled, authorized environments for legitimate security research or testing.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: nyro is not a function
Attempting to call `nyro` as a function after using `const nyro = require('nyro');` in a CommonJS module, or due to incorrect default import in ESM.
fix
For ESM, ensure `import nyro from 'nyro';` is used. For CommonJS, if the library is ESM-only in v2+, you might need `const { default: nyro } = await import('nyro');` or configure your environment for ESM.
ERR_REQUIRE_ESM: require() of ES Module .../node_modules/nyro/index.mjs from ... not supported.
You are attempting to `require()` Nyro (which is an ESM module) from a CommonJS module, or your Node.js environment is not configured for ESM.
fix
Either convert your consuming module to ESM by adding `"type": "module"` to your `package.json` and using `import` statements, or use a dynamic import: `const { default: nyro } = await import('nyro');`.
Property 'body' does not exist on type 'NyroResponse<any>'
When using TypeScript, the inferred type of the response might not match the expected structure, or the `bodySchema` is incorrectly defined.
fix
Ensure `bodySchema` correctly reflects the expected runtime shape of the response body. If the schema is dynamic or very complex, you might need to manually assert the type: `const { body } = await nyro(...) as { body: ExpectedBodyType };`
Error: Protocol 'http:' not supported by agent
Incorrect proxy agent configuration, often when mixing HTTP and HTTPS protocols for the proxy or target URL, or using an agent not compatible with the protocol.
fix
Ensure your proxy agent (e.g., `http-proxy-agent`, `https-proxy-agent`, `socks-proxy-agent`) matches the protocol of your proxy server. Also, verify that the `url` in your Nyro request matches the protocol expected by the agent.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources