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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mim-json-proxy

v1.5.6

Published

Man in the middle JSON proxy

Downloads

20

Readme

MIM JSON proxy

NPM Version

A tool which can be used as ‘man in the middle’ proxy. It can be used to sit between two JSON webservices endpoints (e.g. Facebook/Twitter and your application) to intercept the webservices traffic between them and modify it.

Features

  • Possibility to mock entire response and/or request
  • Possibility to mock only part of response and/or request
  • Possibility to mock response status code
  • Simulate delays on service calls
  • Easy way to change endpoints on the fly (i.e. developer / staging)
  • JSON based configuration with JS defined rules for flexibility
  • JSON based configuration is backed up by JSON schema

Getting started (API)

  1. Install the proxy
    npm i mim-json-proxy
  2. In the code
    const JsonProxy = require('mim-json-proxy');
    const proxy = new JsonProxy(options);
    proxy.start();

Getting started (command line)

  1. Install the proxy
    npm install -g mim-json-proxy
  2. Usage:
    mim-json-proxy {OPTIONS}

Examples

Examples can be found in the examples directory.

Options

Options are for API usage and the command line:

  • port: port to open the server on (default 3005)
  • configsDirectory: defines proxy configurations directory (default ./configs)
  • defaultConfigName: defines default configuration name (default proxy-config.json)
  • configUI.enabled: whether to enable the UI for easier proxy config adjustments (default true)
  • configUI.endpoint: path for the config UI (default /config)
  • bodyParserLimit: limit for express bodyParser (default 5mb)
  • cors: cors configuration to pass to express (default {credentials: true})
  • https: whether to start server using https or not (default false)
  • certificates.key: HTTPS certificate key path (default ./certificates/server.key)
  • certificates.cert: HTTPS certificate CRT path (default ./certificates/server.crt)

API

  • start(options): starts the server with provided options
  • addController(path, controller): possibility to define custom controller on the server (i.e. replacing /config)
  • addDynamicRule(endpointName, func): add dynamic rule, the func takes following as argument: { requestBody, responseStatusCode, responseBody, isResponse, isRequest, reqURL, reqMethod }

Developer notes

  • You can use npm start to run the proxy locally
  • Proxy runs on port 3005 by default to relay the communication to webservice. The /config endpoint can be used to adjust the configuration in simple UI
  • configs/proxy-config.json defines rules and endpoints
  • proxy-config.schema.json defines how the above file should look like