0.6.3 • Published 2 years ago

@sayjava/deputy v0.6.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

What is Deputy?

Deputy is an HTTP API mocking server that can aid in rapid application development by mocking endpoints and configuring responses from configurations.

Deputy can also act as a testing server to validate what requests made by system under test.

Dev

Here is a sample mock definition

[
    {
        "request": {
            "path": "/user/(\\d+)/slug/(.*)",
            "params": {
                "output_type": "json|xml"
            }
        },
        "response": {
            "status": 200,
            "headers": {
                "Content-Type": "application/json"
            },
            "body": [
                {
                    "id": "slug-id",
                    "content": "The post content"
                }
            ]
        }
    }
]

Quick Start

With nodejs

npx @sayjava/deputy

With docker

docker run -p 8080:8080 -p 8081:8081 ghcr.io/sayjava/deputy

and test a sample endpoint

curl http://localhost:8080/who-am-i

Features

Examples

Programitcally

const express = require('express');
const { createExpressMiddleware } = require('@sayjava/deputy');

// mount the mock on a middleware endpoint
const app = express();
app.use('/api', createExpressMiddleware({ mocksFolder: 'fixtures' }));
app.listen(3000, () => console.log('server started'));

Usage Scenarios

Here are some setup scenarios that deputy can be used to aid development and testing

Transparently Mock & Forward API requests

Simulate unready APIs by mocking some APIs and have other requests transparently forwarded to remote APIs See the examples/commerce folder using that uses the next/commerce + deputy

Dev

Application Testing

Simulate complex HTTP requests and response scenarios in test environments

Test

see the Mock Guide

Deputy UI

By default, Deputy server can be reached at http://localhost:8081.

Logs View

View and inspect http requests and responses from the Logs interface in realtime as requests are received

Logs

Visualize

Deputy automatically creates a sequence diagram of requests it receives

Visualize

Mocking Interface

Mocks can be imported, exported, edited, cloned, disabled, and enabled from Deputy UI

Mocking Interface

Full Documentation

Full Documentation

0.6.3

2 years ago

0.6.2

2 years ago

0.6.0

2 years ago

0.5.7

2 years ago

0.5.6

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.5

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.3.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.6

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago