Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@zemke/http-mock

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zemke/http-mock

Serve JSON mocks conveniently.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

http-mock

Serve JSON mocks conveniently.

Usage

// Start server on port 3333.
const httpMock = require('@zemke/http-mock')(3333);

// When http://localhost:3333/api/tournament is requested
// respond with contents of the JSON file under the given path.
httpMock.add('/api/tournament', __dirname + '/mocks/api_tournament.json');

API

add(urlMatcher: string | RegExp, mock: string | object | Function<http.IncomingMessage, object>)

Add a new mock for the given URL pattern. Performs a replace, if the URL pattern already exists.

urlMatcher — May be a string to match the exact path or a regular expression.

mock — A path to a JSON file or inline JSON or a handler function with params http.IncomingMessage and the POST payload.

clean()

Remove all mocks.

Keywords

FAQs

Package last updated on 24 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc