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 🙏

© 2026 – Pkg Stats / Ryan Hefner

panda-mock-server

v0.4.0

Published

simple app to mock requests

Readme

panda-mock-server

Main purpose of this pet-project was to make simple mock server with UI configuration, to work with Express and Node. But it can be used in development if:

  • you have contracts but not working api
  • want to test your app and don't want to make all steps to reproduce api-response

Table of Contents

Getting started

First, install the module:

npm i panda-mock-server --save-dev 

There are two ways of start the app:

With the CLI

npx panda-mock-server start [mock_port] [settings_port]

With NPM Scripts

NPM package.json scripts are the way to run locally installed binaries. Simply define a script as such:

{
  "scripts": {
    "mock_server": "panda-mock-server start"
  }
}

And run the following in your terminal/console:

npm run mock_server

In case of success you can find the messages about ports in console.

Usage

After server had been started you can specify http://localhost:[mock_port] as api-url for your web-app and track requests or configure responses on http://localhost:[settings_port].

Configuration

The server supports only JSON http requests.

You can define different responses for different paths and methods.

A response can be static or use fields from your request, the following fields are available:

  • body - request body (empty object for GET request)
  • path - request path
  • method - request method (supports GET, POST, PUT, DELETE and PATCH)
  • query - object containing request query

Defining response

To define response you have to fill mocks form in the settings app, specify path, method, response template and variables. A variable contains of name ( string values in template, can be nested) and path to value in request object (null will be returned if path cannot be resolved). Variables can be set as object with keys - variable names and values - paths.

Example

Suppose we create POST mock for path / mock with this template:

{
  "greeting": "$greet_var",
  "name": "$name_var",
  "request": "$req_var"
}

and following variables:

{
  "$req_var": [],
  "$name_var": ["query", "name"],
  "$greet_var": ["body","greeting"]
}

Now by this request

fetch("http://localhost:8002/?name=world", {
"body": "{\"greeting\":\"hello\"}",
"method": "POST",
})

we will get following result

{
  greeting: "hello"
  name: "world"
  request: {
    body: {greeting: "hello"},
    method: "POST",
    query: { name: "world" },
    path: "/",
  }
}

Saving mocks

Server stores all mocks in memory, so you can save current mocks state using files dialog.

Development

To start server and client in development mode or make some fixes

  • Download source code and install dependencies
  • Configure ports using .env file
  npm i
  • Start dev-server with isolated client
  npm run dev:client
  • Start dev-server with hot reload
  npm run dev:server

Next steps

  • ui - more convenient way to set templates and variables
  • ui - add notifications on settings changes and errors
  • ui - avoid using dialogs for forms
  • ui - avoid using React
  • ui - refactor file structure
  • server - refactor services to simplify dependency graph
  • server - start http listener from settings