Coder Social home page Coder Social logo

egg-whistle's Introduction

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

egg-whistle's People

Contributors

whxaxes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.