https://github.com/orisano/osniffer
https://github.com/orisano/osniffer
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/orisano/osniffer
- Owner: orisano
- License: mit
- Created: 2017-05-29T13:50:36.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T13:27:11.000Z (over 5 years ago)
- Last Synced: 2025-03-25T05:34:31.022Z (over 1 year ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# osniffer
HTTP通信を覗き見るためのプロキシを作るライブラリです.
## Install
```bash
npm install osniffer
```
## Requirements
Node.js >= 7.6.0
## Example
content-typeがapplication/jsonの通信をconsoleに出力する例
```js
const zlib = require("zlib");
const es = require("event-stream");
const Sniffer = require("osniffer");
const sniffer = new Sniffer();
sniffer.use(async (ctx, next) => {
if (ctx.response.headers["content-type"] === "application/json") {
await next();
}
});
sniffer.use(async (ctx, next) => {
ctx.response
.pipe(zlib.createGunzip())
.pipe(es.wait())
.pipe(es.parse())
.pipe(es.map(x => console.log(x)));
await next();
});
sniffer.listen(8080);
```
## Author
Nao Yonashiro (@orisano)
## License
MIT