New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

http-mockserver

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-mockserver - npm Package Compare versions

Comparing version 2.2.0 to 2.2.2

3

package.json
{
"name": "http-mockserver",
"description": "Testing made easy with mocked http servers",
"version": "2.2.0",
"version": "2.2.2",
"license": "MIT",

@@ -31,2 +31,3 @@ "jest": {

"express": "4.14.0",
"express-xml-bodyparser": "^0.3.0",
"http-proxy": "1.16.2",

@@ -33,0 +34,0 @@ "lodash": "4.17.4",

@@ -36,6 +36,2 @@ class MockServerFactory {

addMocks (...args) {
return this.addMocks(...args);
}
sendData (options) {

@@ -42,0 +38,0 @@ return this.service.sendData(this.port, options);

@@ -69,6 +69,2 @@ const Q = require('q');

clientService.addMocks = function (...mocks) {
return Q.all(mocks.map(clientService.addMock));
};
clientService.sendData = function (port, options) {

@@ -75,0 +71,0 @@ return req({

@@ -10,2 +10,3 @@ const _ = require('lodash');

const pathRegexp = require('path-to-regexp');
const xmlparser = require('express-xml-bodyparser');

@@ -20,2 +21,3 @@ class Listener {

app.use(bodyParser.text());
app.use(xmlparser({trim: false, explicitArray: false}));
app.use((req, res, next) => {

@@ -48,10 +50,7 @@ requestLogService.addEntry(req, res);

this.mocks[uri] = this.mocks[uri] || {};
// Register mock if it hasn't been registered before
if (!this.mocks[uri][method]) {
this.app[method.toLowerCase()](uri, (req, res) => {
return this.mocks[uri][method].handler(req, res);
});
const oldMock = this.mocks[uri][method];
if (oldMock) {
// close pending requests
oldMock.clients.forEach(client => client.end());
}
this.mocks[uri][method] = {

@@ -63,2 +62,9 @@ options: options,

};
// Register mock if it hasn't been registered before
if (!oldMock) {
this.app[method.toLowerCase()](uri, (req, res) => {
return this.mocks[uri][method].handler(req, res);
});
}
}

@@ -65,0 +71,0 @@

@@ -31,2 +31,6 @@ const Listener = require('./Listener');

if (!isValidHttpMethod(options.method)) {
throw new Error(`"${options.method}" is not a valid http method`);
}
const listener = listeners[port] || listenerService.addListener(port);

@@ -68,2 +72,7 @@ const hasMock = listener.get(options.uri, options.method);

function isValidHttpMethod (method) {
const methods = require('http').METHODS;
return methods.includes(method.toUpperCase());
}
module.exports = listenerService;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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