@confluentinc/mox
hybrid proxy and mock server
Last updated 3 months ago by spanwar .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install @confluentinc/mox 
SYNC missed versions from official npm registry.

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

Current Tags

  • 0.1.2                                ...           latest (3 months ago)

3 Versions

  • 0.1.2                                ...           3 months ago
  • 0.1.1                                ...           4 months ago
  • 0.1.0                                ...           4 months ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 3
Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |