1.2.0 • Published 6 years ago

egg-whistle v1.2.0

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

egg-whistle

NPM version build status Test coverage Appveyor status David deps Known Vulnerabilities

Using whistle in egg application.

What is whistle

Whistle is a great web debugging tool based on Nodejs.

see https://github.com/avwo/whistle

Install

$ npm install egg-whistle --save

or

$ yarn add egg-whistle --save

Usage

// config/plugin.js

exports.whistle = {
  enable: true,
  env: [ 'local', 'test' ],
  package: 'egg-whistle',
};

Starting the egg application and visit http://{your app host}:{your app port}/__whistle__

eg.

$ npx egg-bin dev

open whistle

$ open http://127.0.0.1:7001/__whistle__

After application started, The http request client in egg ( app.httpclient or ctx.httpclient ) will send requests through whistle proxy, and capture the request info in whistle dashboard.

Proxy Custom Requests

egg-whistle only proxy the requests sent by app.httpclient or ctx.httpclient ( includes ctx.curl or app.curl ) in egg by default. If you want to proxy your own requests( like http.request or websocket ), app.whistle.proxyAgent may works for you.

http

// app.js

const http = require('http');
module.exports = app => {
  app.whistle.on('ready', () => {
    http.request('http://xxx.com/xxx', { agent: app.whistle.proxyAgent });
  });
};

websocket

// app.js

const ws = require('WebSocket');
module.exports = app => {
  app.whistle.on('ready', () => {
    const socket = new WebSocket('ws://xxx.com/xxx', {
      agent: app.whistle.proxyAgent,
    });
  });
};

global agent

// app.js

const http = require('http');
module.exports = app => {
  app.whistle.on('ready', () => {
    http.globalAgent = app.whistle.proxyAgent;
  });
};

Configuration

// config/config.default.js

exports.whistle = {
  // route: '/__whistle__', // whistle url
  // ignore: undefined, // Array<RegExp> | RegExp, eg. /\/test\/.*/ or [ /\/test\/.*/ ]
  // storage: path.resolve(appInfo.root, 'logs/whistle'),
  // timeout: 3600,
  // see https://github.com/avwo/whistle to know more configuration
}

plugin config

  • route whistle dashboard path
  • ignore ignore urlArray<RegExp> | RegExp, eg. /\/test\/.*/ or [ /\/test\/.*/ ] only works for httpclient in egg.

whistle config

See https://github.com/avwo/whistle#install--setup ( support the most configuration of whistle except localUIHost host port uiport version )

Lincense

MIT

1.2.0

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago