This file provides guidance to Claude Code (claude.ai/code) and other agents when working with code in this repository.
This is request-promise-native, a Promise-enabled wrapper for the HTTP request library. It uses native ES6+ promises (not Bluebird) and is a fork maintained by Automattic that uses @cypress/request instead of the deprecated original request package.
# Run linting
npm run lint
# Auto-fix linting issues
npm run lint:fix
# Run all tests (both main tests and promise-core tests)
npm test
# Check for unused dependencies
npm run check-dependencies
# Verify TypeScript definitions
npm run check-dtsTests are run with Mocha in two separate test suites:
- Main package tests:
test/spec/request-test.js - Promise core tests:
deps/promise-core/test/spec/
Both test suites run sequentially with the npm test command.
The package has a unique architecture that wraps the request library with promise functionality:
-
Entry point (
lib/rp.js):- Uses
stealthy-requireto load a fresh instance ofrequestto avoid polluting user's require cache - Configures promise plumbing with native
Promiseimplementation - Exposes
then,catch, andpromisemethods on request objects
- Uses
-
Promise Core (
deps/promise-core/):- Contains the core promise wrapping logic embedded in this repository
configure/request2.js: Intercepts therequest.Request.prototype.initmethod to inject promise functionalitylib/plumbing.js: Core promise integration logic that wraps request callbacks with promise resolve/rejectlib/errors.js: Custom error classes (RequestError,StatusCodeError,TransformError)
-
Error Handling:
RequestError: Network/request-level errorsStatusCodeError: Non-2xx status codes whensimple: true(default)TransformError: Errors thrown during response transformation
- Promise interception: The package modifies
request's prototype to inject promise handling before the original init method runs - Transform functions: Optional response transformers can be applied, with special handling for
transform2xxOnlyoption - Options:
simple(default: true): Reject on non-2xx status codesresolveWithFullResponse(default: false): Resolve with full response object instead of just bodytransform2xxOnly(default: true): Only transform 2xx responses
- Uses
@cypress/request(aliased asrequest) because the originalrequestis deprecated qsis pinned to v6.14.2 via package.json overrides- Requires Node.js >=20.x
- This package maintains API compatibility with
request-promisebut uses native promises instead of Bluebird - The
stealthy-requirepattern ensures users can still require an unalteredrequestinstance if needed - The promise-core dependency is embedded in
deps/rather than being an external npm package