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

@loopback/http-caching-proxy

Package Overview
Dependencies
Maintainers
7
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loopback/http-caching-proxy - npm Package Compare versions

Comparing version 1.1.16 to 1.2.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [1.2.0](https://github.com/strongloop/loopback-next/compare/@loopback/http-caching-proxy@1.1.16...@loopback/http-caching-proxy@1.2.0) (2019-10-24)
### Features
* **http-caching-proxy:** add timeout and improve error logging ([72cd177](https://github.com/strongloop/loopback-next/commit/72cd17722174690355b220fd4127112b0edc67f2))
## [1.1.16](https://github.com/strongloop/loopback-next/compare/@loopback/http-caching-proxy@1.1.15...@loopback/http-caching-proxy@1.1.16) (2019-10-07)

@@ -8,0 +19,0 @@

@@ -20,2 +20,10 @@ /// <reference types="node" />

port?: number;
/**
* A flag if the error should be logged
*/
logError?: boolean;
/**
* Timeout to connect to the target service
*/
timeout?: number;
}

@@ -22,0 +30,0 @@ /**

15

dist/http-caching-proxy.js

@@ -12,6 +12,8 @@ "use strict";

const cacache = require('cacache');
const debug = debugFactory('loopback:caching-proxy');
const debug = debugFactory('loopback:http-caching-proxy');
const DEFAULT_OPTIONS = {
port: 0,
ttl: 24 * 60 * 60 * 1000,
logError: true,
timeout: 0,
};

@@ -62,3 +64,3 @@ /**

response.statusCode = error.name === 'RequestError' ? 502 : 500;
response.end();
response.end(error.message);
};

@@ -103,2 +105,3 @@ try {

async _forwardRequest(clientRequest, clientResponse) {
debug('Forward request to %s %s', clientRequest.method, clientRequest.url);
const backendResponse = await makeRequest({

@@ -111,2 +114,3 @@ resolveWithFullResponse: true,

body: clientRequest,
timeout: this._options.timeout || undefined,
});

@@ -136,3 +140,8 @@ debug('Got response for %s %s -> %s', clientRequest.method, clientRequest.url, backendResponse.statusCode, backendResponse.headers);

logError(request, error) {
console.log('Cannot proxy %s %s.', request.method, request.url, error.stack || error);
if (this._options.logError) {
console.error('Cannot proxy %s %s.', request.method, request.url, error.stack || error);
}
else {
debug('Cannot proxy %s %s.', request.method, request.url, error.stack || error);
}
}

@@ -139,0 +148,0 @@ }

12

package.json
{
"name": "@loopback/http-caching-proxy",
"version": "1.1.16",
"version": "1.2.0",
"description": "A caching HTTP proxy for integration tests. NOT SUITABLE FOR PRODUCTION USE!",

@@ -27,7 +27,7 @@ "engines": {

"devDependencies": {
"@loopback/build": "^2.0.14",
"@loopback/eslint-config": "^4.1.2",
"@loopback/testlab": "^1.9.2",
"@loopback/build": "^2.0.15",
"@loopback/eslint-config": "^4.1.3",
"@loopback/testlab": "^1.9.3",
"@types/debug": "^4.1.5",
"@types/node": "^10.14.20",
"@types/node": "^10.17.0",
"@types/request-promise-native": "^1.0.17",

@@ -60,3 +60,3 @@ "@types/rimraf": "^2.0.2",

},
"gitHead": "e0eddb107f0e788a4d37cca74b88f3bcd32d6036"
"gitHead": "d7c3cb9d7bd3215bfc6e6ed996416bbb8e3163d3"
}

@@ -20,3 +20,3 @@ // Copyright IBM Corp. 2018,2019. All Rights Reserved.

const debug = debugFactory('loopback:caching-proxy');
const debug = debugFactory('loopback:http-caching-proxy');

@@ -42,2 +42,12 @@ export interface ProxyOptions {

port?: number;
/**
* A flag if the error should be logged
*/
logError?: boolean;
/**
* Timeout to connect to the target service
*/
timeout?: number;
}

@@ -48,2 +58,4 @@

ttl: 24 * 60 * 60 * 1000,
logError: true,
timeout: 0,
};

@@ -119,3 +131,3 @@

response.statusCode = error.name === 'RequestError' ? 502 : 500;
response.end();
response.end(error.message);
};

@@ -181,2 +193,3 @@

) {
debug('Forward request to %s %s', clientRequest.method, clientRequest.url);
const backendResponse = await makeRequest({

@@ -190,2 +203,3 @@ resolveWithFullResponse: true,

body: clientRequest,
timeout: this._options.timeout || undefined,
});

@@ -235,9 +249,18 @@

public logError(request: IncomingMessage, error: Error) {
console.log(
'Cannot proxy %s %s.',
request.method,
request.url,
error.stack || error,
);
if (this._options.logError) {
console.error(
'Cannot proxy %s %s.',
request.method,
request.url,
error.stack || error,
);
} else {
debug(
'Cannot proxy %s %s.',
request.method,
request.url,
error.stack || error,
);
}
}
}

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