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

uuaper

v3.6.0

Published

Proxy tool based on nodejs for front-end development

Downloads

127

Readme

Uuaper

NPM Version NODE Version OSX Build LINUX Build

Proxy tool based on NodeJS for front-end development.

Feature

  • 前后端分离,前端会有跨域问题,本工具提供server端proxy :)
  • 自动登录

Install

    npm install --save-dev uuaper

配置项

| name | detail | | :----- | :----- | | targer | proxy url | | debug | default: false | | headers | request headers | | mock | mock local files, default: false | | cache | cache dir, only cache content-type is json request | | server | build-in server settings, include(port, staticPath, proxyPath) | | auth | auth logic |

auth

| name | detail | | :----- | :----- | | getAuth(cb) | you auth logic | | forwardCookie(cb) | before make sure cookie | | retry(res, data) | retry logic | | auth setting | auth bird-auth |

Usage

自定义headers & 启动server

const uuaper = require('uuaper');
const uupp = new uuaper({
    target: 'http://xxx.xxx.com/',
    headers: {
        cookie: 'xxx'
    },
    debug: true,
    server: {
        port: 1337,
        staticPath: __dirname,
        proxyPath: ['/aaa'] // 需要转发的context路径,譬如/aaa下面的所有请求都走proxy
    }
});

结合express使用实现接口转发功能

const express = require('express');
const app = express();

const uuaper = require('uuaper');
app.use('/api', new uuaper({
    target: 'http://xxx.github.com/',
    debug: true,
    headers: {
        refer: 'http://xxx.com'
    },
    cache: './cache'
}));

自动认证

const uuaper = require('uuaper');
const uupp = new uuaper({
    target: 'http://xxx.xxx.com/',
    auth: {
        username: 'xxx',
        password: 'xxx',
        server: 'http://xxx.xxx.com/authorize?service=xxxx',
        retry: function(res, data) {
            return +res.statusCode === 403;
        }
    }
});

手动设置 cookie 内容

const uuaper = require('uuaper');
const uupp = new uuaper({
    target: 'http://xxx.xxx.com/',
    auth: {
        username: 'xxx',
        password: 'xxx',
        type: 1, // default 1 is username and password; 3 is username and verification code.
        server: 'http://xxx.xxx.com/authorize?service=xxxx',
        retry: function(res, data) {
            return +res.statusCode === 403;
        },
        getAuth: function(cb) {
            cb('your cookies');
        }
    }
});

自动认证

const uuaper = require('uuaper');
const uupp = new uuaper({
    target: 'http://xxx.xxx.com/',
    auth: {
        type: 'passport',
        username: 'xxx',
        password: 'xxx',
        server: 'https://passport.qatest.xxx.com/', //default passport.xxx.com
        forwardCookie: function (cb) {
            // use `uuaper.client` do something to get extrenal cookie
            uuaper.client.get('xxx.xxxx.com', function () {
                cb && cb(uuaper.client.get_cookies_string());
            });
        }
    }
});

History

  • [3.5.3] 升级 bird-auth 版本,移除无效依赖包。
  • [3.5.2] 优化 url 验证逻辑,调整为正则匹配请求头的方式。
  • [3.5.1] 修复 SSE 通信没有触发 close 事件错误,增加 end 操作。
  • [3.5.0] 新增支持 SSE 请求的代理
  • [3.4.0] 切换默认配置,由 login 调整为使用 authorize,以便于更好的接入。
  • [3.3.3] 移除临时 cookie 的存储,统一使用 client 获取
  • [3.3.2] 支持服务启动后,cookie 的更新
  • [3.3.1] 支持验证码方式
  • [3.3.0] 升级bird-auth,修复 token 获取失效问题。
  • [3.2.0] 升级bird-auth,兼容新版验证机制
  • [3.1.4] 修复接口出错,导致服务不能启动问题
  • [3.1.3] 代码优化,修复缓存目录错误
  • [3.1.0] 修复重构代码导致的runProxy错误,移除es-promise和fs-path包。
  • [3.0.0] update new auth.
  • [2.0.9] update bird-auth.
  • [2.0.8] fix fsPath.writeFile error
  • [2.0.7] add request body size limit setting
  • [2.0.6] 支持自定义 auth logic
  • [2.0.5] 增加 xxxx 支持 & headers bugfix
  • [2.0.0] 配置项优化
  • [1.3.4] content-type处理优化
  • [1.3.3] 增加content-typestream判断
  • [1.3.1] rejectUnauthorized: false处理https证书问题
  • [1.3.0] 重构proxy模块,也许是该项目最大的一次重构
  • [1.2.6] res.headers原封不动返回,来解决流形式响应
  • [1.2.3] 增加cookie参数,如果配置,就不使用默认的uuap自动获取方式
  • [1.1.0] 增加接口数据mock功能
  • [1.0.x] 重构,使用bird-auth包进行cookie获取,同时优化内置server
  • [0.1.7] 老版本