@apihero/node
TypeScript icon, indicating that this package has built-in type declarations

1.3.16 • Public • Published

@apihero/node

Installation

npm install @apihero/node

Usage

Automatically proxy all 3rd-party requests through API Hero in Node.js

import { setupProxy } from "@apihero/node";

const proxy = setupProxy({
  projectKey: "hero_123abc",
  url: "https://proxy.apihero.run",
});

// Start intercepting requests and sending them to https://proxy.apihero.run
proxy.start();

// You can always stop intercepting requests
proxy.stop();

You can also setup matchers for only capturing some traffic:

import { setupProxy } from "@apihero/node";

const proxy = setupProxy({
  allow: [
    "https://api.github.com/*",
    "https://api.twitter.com/users/*",
    { url: "https://httpbin.org/*", method: "GET" },
  ],
  projectKey: "hero_123abc",
  url: "https://proxy.apihero.run",
});

// Start intercepting requests and sending them to https://proxy.apihero.run
proxy.start();

Capture all traffic except the matchers in the deny option:

import { setupProxy } from "@apihero/node";

const proxy = setupProxy({
  deny: ["https://myprivateapi.dev/*"]
  projectKey: "hero_123abc",
  url: "https://proxy.apihero.run",
});

// Start intercepting requests and sending them to https://proxy.apihero.run
proxy.start();

Readme

Keywords

none

Package Sidebar

Install

npm i @apihero/node

Weekly Downloads

3

Version

1.3.16

License

MIT

Unpacked Size

184 kB

Total Files

6

Last publish

Collaborators

  • mattaitken
  • ericallam