npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-nproxy

v1.4.3-1

Published

A cli/gulp-plugin proxy tool specialized in file replacing. fork from Goddy Zhao <[email protected]> nproxy

Downloads

4

Readme

gulp-nproxy

A gulp http proxy plugin. Full support nproxy feature.

Why NProxy

Maybe you have such question as why NProxy when we have Fiddler, Charles, Rythem and Tinyproxy. Yes, there is no doubt that they are all great tools, however they don't meet my requirements:

  • Support Mac, Linux and Windows(especially Mac and Linux)
  • Support replacing combo files with separated source files
  • Support directory mapping

This is the main reason why NProxy is here. Besides, NProxy can improve the efficiency of my daily development for enterprise-level product with a bunch of complex building processes, which cost me lots of time.

I've written a post named NProxy: The Mjolnir for UI Developers and a keynote NProxy: A Sharp Weapon for UI Developers to explain my reason for developing NProxy in detail.

Features

  • Support Mac, Linux and Windows
  • Support both single file and combo file replacing
  • Support directory mapping with any files
  • Support both HTTP and HTTPS

Installation

npm install -g gulp-nproxy (node >= v0.8.x is required)

Usage

var nproxy = require('gulp-nproxy');
nproxy({
  timeout: 10, // Specify the request timeout (5 seconds by default)
  debug: false, // display debug log
  version: '', // output the version number
  port: 8989, // Specify the port nproxy will listen on(8989 by default)

  // redirect rule
  rule: [
    {
      pattern: '(.*).js',      // Match url you wanna replace
      responder: '/Users/isken/projects/nproxy/test-script.js'
    },
  ]
});

Template of Replace Rule

[
      // 1. replace single file with local one
      {
        pattern: 'homepage.js',      // Match url you wanna replace
        responder:  "/home/goddyzhao/workspace/homepage.js"
      },

      // 2. replace single file with web file
      {
        pattern: 'homepage.js',      // Match url you wanna replace
        responder:  "http://www.anotherwebsite.com/assets/js/homepage2.js"
      },

      // 3. replace combo file with src with absolute file path
      {
        pattern: 'group/homepageTileFramework.*.js',
        responder: [
          '/home/goddyzhao/workspace/webapp/ui/homepage/js/a.js',
          '/home/goddyzhao/workspace/webapp/ui/homepage/js/b.js',
          '/home/goddyzhao/workspace/webapp/ui/homepage/js/c.js'
        ]
      },

      // 4. replace combo file with src with relative file path and specified dir
      {
        pattern: 'group/homepageTileFramework.*.js',
        responder: {
          dir: '/home/goddyzhao/workspace/webapp/ui/homepage/js',
          src: [
            'a.js',
            'b.js',
            'c.js'
          ]
        }
      },

      // 5. Map server image directory to local image directory
      {
        pattern: 'ui/homepage/img',  // must be a string
        responder: '/home/goddyzhao/image/' //must be a absolute directory path
      },

      // 6. Write responder with regular expression variables like $1, $2
      {
        pattern: /https?:\/\/[\w\.]*(?::\d+)?\/ui\/(.*)_dev\.(\w+)/,
        responder: 'http://localhost/proxy/$1.$2'
      },

      // 7. Map server image directory to local image directory with regular expression
      // This simple rule can replace multiple directories to corresponding locale ones
      // For Example,
      //   http://host:port/ui/a/img/... => /home/a/image/...
      //   http://host:port/ui/b/img/... => /home/b/image/...
      //   http://host:port/ui/c/img/... => /home/c/image/...
      //   ...
      {
        pattern: /ui\/(.*)\/img\//,
        responder: '/home/$1/image/'
      }
];

License

MIT