@confluentinc/mox

中文文档
0.1.3发布于 2020/12/18MITESM + CJS近 30 天下载 6627

hybrid proxy and mock server

原始使用文档
文档目录4 节
  1. Why this exists
  2. Installation
  3. The basics
  4. Documentation

Mox

A node.js developer tool written on top of express.js. Mox is a cross between a mock and a proxy server.

See here for the NPM package

Why this exists

Mox's purpose is to bridge the gap between mock server usage and live backend usage. Frontend development processes typically fall into one of two camps:

  • Build off of mock servers
  • Build off of a local or hosted development backend

Mox is a tool that helps you use both at the same time. It also provides a few other APIs that make the second camp a lot easier.

Some key features:

  • Read or modify requests/responses in-flight
  • Mock individual endpoints or set of endpoints
  • Express.js based routing and pattern matching

Installation

Install this package through npm or yarn.

npm install @confluentinc/mox

The basics

Here's a quick example of what it takes to configure the server, perform a simple mock, and get it running.

import { MoxServer } from '@confluentinc/mox';

const server = new MoxServer({ targetUrl: 'https://dev.server', listenPort: 3005 });
const router = server.getRouter();

router.get('/api/route-to-mock').mock({ foo: 'bar' });

server.start();

Mox supports most common HTTP methods, including HEAD, OPTIONS, and PATCH. It also supports the all matcher from express.js which matches all methods.

In the above example, router.get matches the same way app.get would in express.

Documentation

More detailed API reference

版本与发布记录

@confluentinc/mox 共发布 4 个版本,首次发布于 2020/01/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.3latest2020/12/185 年前
0.1.22020/03/136 年前
0.1.12020/01/226 年前
0.1.02020/01/226 年前

关于 @confluentinc/mox 的常见问题

@confluentinc/mox 是什么?

hybrid proxy and mock server

如何安装 @confluentinc/mox?

在项目目录运行 npm install @confluentinc/mox,或使用 pnpm add / yarn add / bun add。

@confluentinc/mox 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/confluentinc__mox 是否存在。

@confluentinc/mox 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@confluentinc/mox 可以商用吗?

@confluentinc/mox 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@confluentinc/mox 的下载量有多少?

根据 npm 官方下载统计,@confluentinc/mox 在 2026/10/11 – 2026/11/09 这 30 天内被下载 6,627 次,日均约 221 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@confluentinc/mox 还在维护吗?

最新版本 0.1.3 发布于 2020/12/18(5 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/01/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。