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

lonesome-js

v0.2.1

Published

基于 Pingora 的 Node.js 高性能可编程反向代理绑定。

Readme

lonesome-js

基于 Pingora 的 Node.js 高性能可编程反向代理绑定。

English README

为什么使用 lonesome-js

  • 基于 Pingora,具备现代异步代理的性能与稳定性基础。
  • 通过 addOrUpdate 支持 Node.js 运行时路由热更新,无需重启进程。
  • 路由匹配与中间件条件由 CEL 表达式驱动。
  • 提供 virtual_js upstream,可在进程内接入 Node.js 处理链路。
  • 提供认证、Header 改写、重定向、缓存、压缩、CORS、限流与可编程拦截等路由中间件。

与传统反向代理的设计差异

多数传统反向代理偏向静态配置文件与 reload 流程;lonesome-js 更偏向运行时 API 与可编程流量编排。

基于 CEL 的匹配与逻辑表达

路由规则、中间件条件和动态值都可以通过 CEL 表达式描述,而不是只能依赖固定指令。

示例:

  • 路由匹配:"Method('POST') && PathPrefix('/api') && Query('debug', '1')"
  • 条件中间件:rule: "Header('x-env', 'prod')"
  • 动态值:expression: "MethodValue() + '-' + QueryValue('id')"

virtual_js 上游能力

除 TCP/Unix socket upstream 外,virtual_js 可以把请求桥接到进程内 JavaScript handler。适合构建内部适配层或可编程后端,无需额外暴露网络端口。

快速开始

1. 安装

npm i lonesome-js

Windows on arm 预编译绑定暂不可用,建议临时使用 WSL,或者自行构建。

2. 启动代理服务

import { LonesomeServer } from 'lonesome-js'

const server = new LonesomeServer()

server.start({
  listeners: [{ kind: 'tcp', addr: '127.0.0.1:8080' }],
})

3. 添加基础路由

server.addOrUpdate({
  id: 'basic-proxy',
  matcher: { rule: "PathPrefix('/api')", priority: 50 },
  middlewares: [],
  upstreams: [
    { kind: 'tcp', address: '127.0.0.1:9000', tls: false, sni: '', weight: 1 },
  ],
  loadBalancer: { algorithm: 'round_robin' },
})

4. 运行时热更新路由

server.addOrUpdate({
  id: 'basic-proxy',
  matcher: { rule: "PathPrefix('/api')", priority: 50 },
  middlewares: [{ type: 'respond', config: { status: 418, body: 'teapot' } }],
  upstreams: [
    { kind: 'tcp', address: '127.0.0.1:9000', tls: false, sni: '', weight: 1 },
  ],
})

运行时兼容性

  • 主要目标运行时:通过 npm 包在 Node.js 中使用。
  • Deno 可通过 npm:lonesome-js 引入,适用于允许 npm/native binding 的本地或服务端场景。示例应用见:example/deno-app。

文档

以下 docs/ 文档当前为英文: