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-bird

v0.2.4

Published

bird-v2

Downloads

48

Readme

gulp-bird

起源

  • 起源于bird,但是名字有点误导,并不是一个gulp插件,在bird基础上进行了一些优化并发布到了npm,配置方法和bird一样

功能介绍

基本功能:本地联调解决跨域问题

本地webserver优先寻找对应的本地资源, 如果没找到则会走转发规则,转发规则也没找到才会返回404.

这样假设你有这样一个项目: 本地有如下文件

project
    --- index.html
    --- list.json

targetServer上有如下文件

targetServer
    --- detail.html
    --- detail.json

以peoject目录作为basePath,启动bird server,那么访问localhost:8008/index.html就会加载本地的index.html页面, 访问localhost:8008/detail.html就会加载服务端的页面,ajax请求list.json,返回的是本地的list.json, 请求detail.json,则返回服务器上的detail.json

这样就通过代理服务器绕过了跨域限制。

联调需要身份校验的接口:

在targetServer中配置身份校验信息,则可以帮助我们联调一些需要身份验证的接口

    "headers": {
         "cookie": "xplatform_ge=4ffcc236a075c3e1f5068f172f654bbe9a1f23adc1563138c432b72b0d06261a153cc6f5a40"
    }

特殊规则

可以通过配置规则,走一些特殊的转发规则,请参见下面的使用手册。

使用手册

1、创建一个config.js文件(名称任意)

    var bird = require('gulp-bird');
    //静态服务器配置,可同时配置多个,域名需host到127.0.0.1
    var server = {
        "8008": {
            //静态文件根目录
            "basePath": "/Users/baidu/Desktop/frontEnd/Baidu/Hi-new-backend/src",
            // 是否开启调试模式,true(表示server端不缓存),false(反之)
            "debug": true,
            //忽略的静态文件请求,与此正则匹配的请求将直接走转发规则(可选配置)
            "ignoreRegExp":  /\/js\/urls\.js/g

        }
    };
    //转发规则——静态服务器没有响应的或者忽略的请求将根据一下规则转发
    var transpondRules = {
        "8008": {
            //目标服务器的ip和端口,域名也可,但注意不要被host了
           targetServer: {
                "port": "8274",
                "host": "cp01-hiserver-sandbox1-tc.cp01.baidu.com",
                "replaceHeaders": true, //当为true时,如果cookie or header中有相同key,则替换
                "headers": {
                    "cookie": "xplatform_ge=4ffcc236a075c3e1f5068f172f654bbe9a1f23adc1563138c432b72b0d06261a153cc6f5a40"
                }
            },
            //特殊请求转发,可选配置,内部的host、port和attachHeaders为可选参数
            regExpPath: {
                "/hrlms/rs": {
                    //"host": "10.44.67.14",
                    //"port": "8045",
                    //"attachHeaders": {"app-id": 5},
                    "path": "/hrlms/rs"
                }
            }
        },
        "ajaxOnly": false
    };

    var toolsConf = {
        weinre: {
            open: true, //和移动调试工具条中的vconsole冲突, 当为true时vconsole自动关闭
            port: 9001
        },

        showTools: true //移动端调试工具条,PC端开发可关闭
    };

    bird.start(server, transpondRules, toolsConf);

2、用node执行它

    node config.js

如何开发和贡献代码

npm install
node app.js

然后访问localhost:7676查看效果