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 🙏

© 2026 – Pkg Stats / Ryan Hefner

third.relay

v0.1.8

Published

## 简介

Downloads

0

Readme

third.relay

简介

内网服务映射,类似 frp 和 ngrok,但目前仅作用于 http 服务层面,嵌入到 node 代码中使用

如果有匿名需求,请使用 tor 协议,本服务不做匿名保护

目前支持内容

  • 服务端解析内容后转发请求
  • 服务端与客户端加密传输数据
  • 目前 body 仅支持 text 和 json 格式(后续修改转发方式会全部支持)

使用方法

服务端

docker

依赖 docker-compose

默认为映射 80 端口

git clone https://github.com/Erriy/third.relay-node.js.git &&
cd third.relay-node.js &&
docker-compose up --build

npm

npm i -g third.relay &&
third.relay

启动是否成功判断

curl http://localhost/api/pubkey
# 正常启动的服务应该会输出服务所使用的公钥,为以下格式
#-----BEGIN PGP PUBLIC KEY BLOCK-----
#
#...
#-----END PGP PUBLIC KEY BLOCK-----

客户端

安装

npm i third.relay

使用方法

示例代码在example/client.js

const rdriver = require("third.relay").driver;
const express = require("express");

(async () => {
  // 启动一个express服务用于转发测试
  const app = express();
  app.use(express.text(), express.json(), express.urlencoded());
  app.all(/.*/, (req, res) => {
    res.status(200).json({
      method: req.method,
      url: req.url,
      headers: req.headers,
      body: req.body,
    });
  });
  app.listen(33333);
  // 初始化relay driver,参数为要转发的本地端口
  const rc = await rdriver.init(33333);
  // 连接本机的中转服务,注意,connect执行完成后并不能确定是否已连接成功,需要对事件进行判断
  rc.connect("http://127.0.0.1:80/");
  // connected事件,接收到本事件后才能确定成功连接到服务,rc.relay代表本地端口映射后路径
  rc.on("connected", () => {
    // 访问rc.relay路径等同于访问33333端口
    // http://127.0.0.1:80/relay/${relayid}/ => http://127.0.0.1:33333/
    // http://127.0.0.1:80/relay/${relayid}/hello?name=erriy => http://127.0.0.1:33333/hello?name=erriy
    console.log(rc.relay);
  });
  // reconnect事件表明连接已断开,会自动重连
  rc.on("reconnect", () => {
    console.log("连接断开,正在重新连接");
  });
  // error事件表明连接错误,会自动重连
  rc.on("error", () => {
    console.log("连接错误");
  });
})();

todo

  • [ ] 增加压测脚本
  • [ ] 修改流式转发,根据 http path 识别完转发目标后即进行 pipe 转发操作
  • [ ] 增加缓存功能(或再开个新的服务模块,单独做短期发布功能)
  • [ ] ci 自动构建多版本 docker 镜像