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

mocknode

v1.2.3

Published

A configurable mock server with an intuitive configuration management interface and a http api

Downloads

77

Readme

Mock Node

A configurable mock server with an intuitive configuration management interface and a http api.

More Information...

Build Status

NPM

Mocknode allows you to mock http endpoints quickly and easily. The simple management interface lets you configure how the server responds to different endpoints:

  1. Proxy - Proxies the request to an existing service
  2. Stub - A static response which you can manage in the 'manage stubs' link of the route
  3. Dynamic Stub - Responds with a configured stub if the condition defined evaluates to true

The interface allows every one working on the team to have clear visibility on what routes are being used by an application and all possible responses of the route. Thus making stubs to act as proper documented examples.

You can use mocknode to write integration tests for your application. Dynamic stubs can be used to define strategies which can be asserted in your test scripts. You can have even more granular control on the integration tests by using the http api exposed by mocknode. Use the API to toggle the handle for a route, change the stub which is being responded, etc.

A running instance on heroku

https://mocknode.herokuapp.com/mocknode/ please go easy on this :)

Installing and Runing the server

Standalone

  1. clone/download this repository
  2. make sure you have node and npm installed
  3. run npm install to download required packages
  4. node server.js to run the server

npm global install

  1. npm install -g mocknode
  2. run mocknode to start the server

npm local install

  1. npm install --save mocknode
  2. add an npm script entry in the package.json "mocknode": "mocknode"
  3. run npm run mocknode to start the server

and open https://localhost:3000/mocknode/ in your browser to configure mocknode

Mocknode has a downstream dependency on buffertools which executes a node-gyp during install. A common problem with node-gyp exists nodejs/node-gyp#809. If there are node-gyp errors during 'npm install' an easy fix is to remove the gyp installed on your OS.

The Port

The order of preference for the port on which mocknode runs is:

env variable of process > port option passed > 3000

mocknode --port 4000 starts the server on port 4000, unless a PORT env variable exists for the process.

Mocknode configuration

Open https://localhost:3000/mocknode/ in your browser to configure mocknode

alt tag

All your changes are saved in the config.json file and the stubs folder. This ensures all your changes are saved if you restart mocknode. You can easily backup all of your configuration by making a copy of these files.

Installation directory

If you have installed mocknode as a global npm package

mocknode --location prints the installation path of mocknode.

Logs

mocknode stores logs in the logs/ folder of the installation directory

  1. access.log - logs all requests to mocknode
  2. change.log - logs all configuration change requests made to mocknode

Export and Import config

The config.json file and stubs folder hold all the configuration of mocknode.

mocknode --export creates a mocknode-config.tar file which can be used to setup another instance of mocknode. mocknode --import [file_path] imports a config.tar file to configure mocknode.

HTTP API

Mocknode exposes a series of endpoints which can help you integrate it with your code - [ test scripts for example ]

| enpoint | method | params | | :------------------------------ | --------:| :------------: | | /mocknode/api/config | GET | - | | /mocknode/api/stubconfig | GET | - | | /mocknode/api/getstub | GET | name | | /mocknode/api/modifyroute | POST | route config | | /mocknode/api/deleteroute | GET | route | | /mocknode/api/modifystub | POST | stub config | | /mocknode/api/deletestub | GET | name | | /mocknode/api/modifydynamicstub | POST | stub config | | /mocknode/api/deletedynamicstub | GET | name |

mocknode interface uses the above endpoints to interact with the server, inspect the network of the browser to better understand the parameters used in each api.

Troubleshooting

The config files and the stubs folder mentioned above have all the information regarding your configuration.

License

MIT