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

anymocker

v1.0.3

Published

mock server with fuzzy value based on anyproxy

Downloads

7

Readme

anymocker

A smart mock server based on Anyproxy, can install by typing

   npm install anymocker -g

This illustrate below show how it works:

image

Before all

  • this is a tool using for fine tuning API json response, which based on Anyproxy, so please follow up anyproxy instruction to setup the environment, that's the basis of rules

  • use jsonpath to locate a field in API response

Rule detail

here are some examples about defining a rule

  • replace all API's response(json format), make all name field equal to github, all text field equal to anymocker, that's a global rule
$ anymocker -s save -m $..name=github $..text=anymocker
  • replace api xxx/xxx response(json format), make all name field equal to github, delete all the text field, and then inject a field title, valued devil, that's a api rule
$ anymocker -s save -a xxx/xxx -m $..name=github -d $..text -i $.title=devil
  • when both api and global rules are specified, should notice that for the same field, api will override global, below the api xxx/xxx will mock text field as github, and for other request(global) will mock text field as gitlab
$ anymocker -s save -a xxx/xxx -m $..name=github -d $..text -i $.title=devil -m $..name=gitlab

Fuzzy

if you don't want to fake data so painful, you can just put a FUZZ as the value

  • only number, string and boolean can be fuzzy
  • can randomly return null
  • for number, there are chances to amplify and shrink by multiple
  • for string, there are chances to get an empty ''
$ anymocker -s save -a xxx/xxx -m $..name=FUZZ -d $..text -i $.title=devil -m $..name=gitlab $..text=FUZZ

TODO

for multi apis mock, something need to consider:

if input parameters are like this:

$ anymocker -s save -a api1 -m x -a api2 -m y -i z

you intend to make rules below:

{
  "api": {
    "api1": {
      "mock": [
        x
      ]
    },
    "api2": {
      "mock": [
        y
      ],
      "inject": [
        z
      ]
    }
  }
}

but unfortunately, what you get exactly is:

{
  "api": {
    "api1": {
      "mock": [
        x
      ],
      "inject": [
        z
      ]
    },
    "api2": {
      "mock": [
        y
      ]
    }
  }
}

the latter -i z will be squashed as an api1 rule, that's because anymocker analisis parameters by order. so please, to set a parameter at a prior place, or you just want to make it easy, try anymocker -s save -a api1 -m x -i -a api2 -m y -i z