# pooy-core

> http/https proxy

Latest version **0.1.1** (published 2021-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install pooy-core
pnpm add pooy-core
yarn add pooy-core
bun add pooy-core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2021-12-12 |
| First published | 2019-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.6.0 |
| Dependencies | 5 |
| Unpacked size | 62.8 KB |
| Known vulnerabilities | 0 (+15 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | hxtao |
| Maintainers | hxtao |
| Keywords | proxy, nodejs, http, https, ssl |

## Links

- npm: https://www.npmjs.com/package/pooy-core
- Repository: https://github.com/better-than-better/pooy-core
- Homepage: https://github.com/better-than-better/pooy-core#readme
- Issues: https://github.com/better-than-better/pooy-core/issues
- npm.io page: https://npm.io/package/pooy-core

## Dependencies (5)

- [ora](https://npm.io/package/ora.md) ^4.0.4
- [statuses](https://npm.io/package/statuses.md) ^2.0.0
- [multiparty](https://npm.io/package/multiparty.md) ^4.2.1
- [node-forge](https://npm.io/package/node-forge.md) ^0.9.1
- [compare-versions](https://npm.io/package/compare-versions.md) ^3.6.0

## Recent versions

- 0.1.1 (latest) — 2021-12-12
- 0.1.0 — 2020-05-16
- 0.0.9 — 2020-05-04
- 0.0.8 — 2020-05-03
- 0.0.2 — 2019-10-23
- 0.0.1 — 2019-10-23
- 0.0.1-beta1 — 2019-10-21
- 0.0.1-beta — 2019-10-08

## README

# pooy-core

![Node version](https://img.shields.io/badge/node->%3D7.6.0-brightgreen.svg) ![npm version](https://img.shields.io/npm/v/pooy.svg) ![NPM](https://img.shields.io/npm/l/pooy)

[中文文档](./README-zh.md)

A proxy service based on NodeJS EventEmitter. It can realize request monitoring and packet capture, support modification request body and response body, and provide secondary development capability at each stage of the request.

## Installation

Pooy requires node v7.6.0 or higher for ES2015 and async function support.

⚠️ Because it involves an automatic installation update of the self-signed root certificate, it is necessary to run with the administrator privileges.

```bash
npm install pooy
```

## Example

```js
const Pooy = require('pooy');
const proxy = new Pooy();

proxy.on('error', (err, ctx) => {
  console.log('oops, something went wrong!', err);
  consle.log(ctx);
});

proxy.on('request', (ctx) => {
  consle.log(ctx.method, ctx.protocol, ctx.host, ctx.url);
});

proxy.on('response', (ctx) => {
  ctx.setHeader('proxy-agent', 'pooy');
});

proxy.listen(9696, () => {
  console.log('proxy server run at 9696...');
});
```

## Events

A complete request response in pooy will go through four kinds of events:

- `request`
- `requestEnd`
- `response`
- `responseEnd`

which will trigger the `error` event when an unexpected error occurs.


## Context

In each event callback, there is a `context` object that wraps its own `response` and `request` objects, as well as the original request or response objects `clientRequest` and `remoteResponse` that mount the current event. Additional for easy modification or retrieval of some request or response body related information `context` also provides `setHeader` `getHeader` `removeHeader` `setBody` `getBody` and other series of method functions

## Document

- [proxy.on(eventName, function)](./docs/api.md#proxyon)
- [proxy.listen](./docs/api.md#proxylisten)
- [proxy.useRules](./docs/api.md#proxyuserules)
- [proxy.direct](./docs/api.md#proxydirect)
- [context](./docs/api.md#context)


## TODO

⚠️ Platform compatibility (currently only supports macOS)

## License

[MIT](./LICENSE)

---
_Source: https://npm.io/package/pooy-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
