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

proxyauth

v1.0.4

Published

模拟登陆过程,用于前后端分离开发时,作为中间服务将前端接口代理到测试或线上环境,并添加cookies,以及方便的进行代理方案切换,避免重启编译的耗时。 使用puppeteer进行模拟登陆,会根据set-cookie保存cookie, 在代理中携带。

Downloads

5

Readme

proxyauth

模拟登陆过程,用于前后端分离开发时,作为中间服务将前端接口代理到测试或线上环境,并添加cookies,以及方便的进行代理方案切换,避免重启编译的耗时。 使用puppeteer进行模拟登陆,会根据set-cookie保存cookie, 在代理中携带。

Install

npm i -g proxyauth

Usage

proxyauth

根据提示输入对应内容
配置项目的代理指向当前服务及端口.
例:通过vue-cli创建的项目中,修改vue.config.js

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:5000',
        ws: true,
        changeOrigin: true
      }
    }
  }
}

指令

  • proxyauth clear 清除本地保存的开发者信息
  • proxyauth -p <port> 指定端口
  • proxyauth -t <url> 更新代理URL
  • proxyauth -d 清除本地保存的配置
  • proxyauth -c <config file path> 指定配置文件地址,默认读取 .proxyauth.cfg.json.
  • proxyauth -h 查看帮助
  • proxyauth <any> 等同于执行proxyauth && npm run <any>

Config file (Optional)

创建文件 .proxyauth.cfg.json.

{
  "proxyUrl": "https://example.com",
  "port": 5000,
  "submitSelector": "form [type=submit]",
  "checkNeedLogin": "response => response.statusCode === 302",
  "input": [
    {
      "selector": "form [name=username]",
      "value": "username"
    },
    {
      "selector": "form [name=password]",
      "value": "password"
    }
  ]
}

字段 | 说明 | 必填
-- | -- | --
proxyUrl | 代理地址,访问后必须自动跳转到登陆界面 | 必填
port | 服务端口, 可以将前端项目proxy指向此服务,默认5000 | 必填 checkNeedLogin | 接口代理时已此为依据判断是否需要重新进行登陆过程,例:response => response.statusCode === 401,接口返回状态码为401时,会进行登陆过程。 r默认:response => false |
submitSelector | 提交按钮的选择器(等同于querySelector),按钮存在时进行输入,输入完成会点击提交。默认:form [type=submit] | 必填 input | 用于输入用户名密码等输入项。类型为数组。 | [input].selector | 输入项选择器 | 必填 [input].value | 输入值 |

运行过程中主动切换和刷新登陆

  • 输入 c 根据提示更新代理地址后重新进行登陆过程
  • 输入 r 重新进行登陆过程