open-index/open-npm huggingface dataset:
npm package: 4000
Description: Isomorphic server
Author: Sasha Koss
Latest version: 0.4.1

# 4000
[![4000](http://img.shields.io/npm/v/4000.svg)](https://www.npmjs.org/package/4000) [![Build Status](https://travis-ci.org/kossnocorp/4000.svg?branch=master)](https://travis-ci.org/kossnocorp/4000) [![Stories in Ready](https://badge.waffle.io/kossnocorp/4000.png?label=ready&title=Ready)](https://waffle.io/kossnocorp/4000)

## Installation

```
npm install --save-dev 4000
```
npm package: 402.js
Description: A lightweight wrapper around axios that adds 402 Payment Required retry hooks and pluggable paywall handlers.
Author: Your Name
Latest version: 1.0.0

# 402.js

A tiny axios wrapper that adds **HTTP 402 (Payment Required)** handling via a pluggable callback.

## Install

```bash
npm install 402.js
# or
pnpm add 402.js
```

> If you're publishing this yourself, run `npm publish` inside this folder.

## Usage

```js
import { createClient } from "402.js";

const client = createClient({
  maxRetries: 1,
  onPaymentRequired: async ({ config, error, attempt }) => {
    // TODO: trigger your payment flow here (Stripe, Solana, Pump.fun, etc.)
    // Return true to retry the request after payment succeeds.
    console.log("402 received; attempt:", attempt);
    return false;
  }
});

const res = await client.get("https://api.example.com/protected");
console.log(res.data);
```

## API

### `createClient(options)`

- `maxRetries` (default `1`): number of times to retry after your payment callback returns `true`.
- `onPaymentRequired(ctx)` => `Promise<boolean>`: called when a response is `402`. Return `true` to retry once payment succeeds.
- `axiosConfig`: passed to `axios.create()`.

Returns an object with `{ axios, get, post, put, patch, delete, request }`.

## License

MIT