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 - npm Package Compare versions

Comparing version 2.0.4 to 3.0.0

19

index.js

@@ -23,2 +23,4 @@ const http = require('http');

if (req.method.toUpperCase() === 'OPTIONS') return res.end();
const matchingMocks = mocks.filter(m => urlMatchesPattern(req.url, m[0]));

@@ -39,6 +41,17 @@

try {
res.end(JSON.parse(JSON.stringify(mock)));
if (typeof mock === "object") {
console.log(`Serving inline mock for ${req.url}`);
} catch (e) {
res.end(JSON.stringify(mock));
} else if (typeof mock === "function") {
console.log(`Serving mock from function for ${req.url}`);
if (req.method.toUpperCase() === 'POST') {
let body = "";
req
.on('data', chunk => body += chunk)
.on('end', () => res.end(JSON.stringify(mock(req, JSON.parse(body.toString())))));
} else {
res.end(JSON.stringify(mock(req)));
}
} else {
if (!fs.existsSync(mock)) {

@@ -45,0 +58,0 @@ console.warn(`HTTP500 - ${mock} does not exist.`);

2

package.json
{
"name": "@zemke/http-mock",
"version": "2.0.4",
"version": "3.0.0",
"description": "Serve JSON mocks conveniently.",

@@ -5,0 +5,0 @@ "main": "index.js",

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