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

puer-proxy

v1.0.0

Published

more than a live-reload server , built for efficient frontend development. base on puer add proxy context

Downloads

14

Readme

puer-proxy

NPM version changelog license

more than a live-reload server , built for efficient frontend development

[email protected] 的基础上添加了自定义代理上下文的功能, 主要是为了实现#36的需求, 与 puer-mock 配合来使用(必须规范所有的 mock api 都在一个根路径下, 例如 /api/)

添加了如下命令行参数(都是针对代理功能的), 为了不与原来的 puer 冲突, 修改命令为: puer-proxy

  -c,--context <proxyContext>     proxy context
  -r,--rewrite <pathRewrite>      proxy pathRewrite

PS: 只修改了 lib 目录的代码, 没有同步修改 src 目录中的 .coffee 源码...

puer-proxy 增强功能的使用方法

首先当然得安装了, 全局安装还是仅项目安装都可以, 不过一般推荐全局安装了

npm install puer-proxy -g

假设你要代理的后端接口在 http://localhost:8080, 一般的使用方法为同时指定代理的上下文并使用路径重写功能

puer-proxy -c /api/ -r -t http://localhost:8080

这样达到的效果是: 当请求 http://localhost:8000/api/path/to/something 时将请求代理给 http://localhost:8080/path/to/something 来处理, 默认的 -r 参数会将上下文路径(即这里的 /api/)重写为空字符串再提交给代理的服务器

如果你习惯将所有的 mock api 都定义在 /api/ 路径下, 那么可以更简单的运行下面的命令

puer-proxy -r -t http://localhost:8080

下面详情解释每个参数的含义

  • 自定义代理的上下文(-c,--context), 默认为 /api/

    puer-proxy -c /api/ -t http://localhost:8080

    即当请求 http://localhost:8000/api/path/to/something 时将请求代理给 http://localhost:8080/api/path/to/something 来处理

    注意: 以斜杠结尾, 否则会匹配到 /api123 这样的路径

  • 关闭路径重写功能

    不要在命令行传入 -r 参数, 即达到上面"自定义代理的上下文"例子中的效果

  • 自定义路径重写功能(-r,--rewrite)

    puer-proxy -c /api/ -r /abc/ -t http://localhost:8080

    即当请求 http://localhost:8000/api/path/to/something 时将请求代理给 http://localhost:8080/abc/path/to/something 来处理

puer 原本功能的使用方法

其他使用说明请参考官网文档 leeluolee/puer, 非常感谢 leeluolee/puer 给我们带来了很多效率的提升.