@sitecore-jss/sitecore-jss-proxy
Advanced tools
Comparing version 12.0.0 to 13.0.0
@@ -14,6 +14,7 @@ "use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -55,2 +56,3 @@ }); | ||
var set_cookie_parser_1 = __importDefault(require("set-cookie-parser")); | ||
var http_status_codes_1 = __importDefault(require("http-status-codes")); | ||
var zlib_1 = __importDefault(require("zlib")); // node.js standard lib | ||
@@ -86,3 +88,3 @@ var util_1 = require("./util"); | ||
return __generator(this, function (_a) { | ||
if (proxyResponse.statusCode === 200 || proxyResponse.statusCode === 404) { | ||
if (proxyResponse.statusCode === http_status_codes_1.default.OK || proxyResponse.statusCode === http_status_codes_1.default.NOT_FOUND) { | ||
responseString = void 0; | ||
@@ -123,3 +125,3 @@ if (contentEncoding && | ||
errorResponse = { | ||
statusCode: proxyResponse.statusCode || 500, | ||
statusCode: proxyResponse.statusCode || http_status_codes_1.default.INTERNAL_SERVER_ERROR, | ||
content: proxyResponse.statusMessage || 'Internal Server Error', | ||
@@ -131,3 +133,3 @@ }; | ||
onError = _a.sent(); | ||
errorResponse = __assign({}, errorResponse, onError); | ||
errorResponse = __assign(__assign({}, errorResponse), onError); | ||
_a.label = 2; | ||
@@ -177,3 +179,3 @@ case 2: | ||
} | ||
finalStatusCode = result.status || proxyResponse.statusCode || 200; | ||
finalStatusCode = result.status || proxyResponse.statusCode || http_status_codes_1.default.OK; | ||
if (config.debug) { | ||
@@ -194,3 +196,4 @@ console.log('DEBUG: FINAL response headers for client', JSON.stringify(proxyResponse.headers, null, 2)); | ||
originalWriteHead.apply(serverResponse, [statusCode, headers]); | ||
originalWrite.call(serverResponse, content); | ||
if (content) | ||
originalWrite.call(serverResponse, content); | ||
originalEnd.call(serverResponse); | ||
@@ -212,3 +215,3 @@ } | ||
customViewBag = _a.sent(); | ||
viewBag = __assign({}, viewBag, customViewBag); | ||
viewBag = __assign(__assign({}, viewBag), customViewBag); | ||
_a.label = 2; | ||
@@ -241,3 +244,3 @@ case 2: return [2 /*return*/, viewBag]; | ||
// we are going to set our own status code if rendering fails | ||
serverResponse.writeHead = function () { }; | ||
serverResponse.writeHead = function () { return serverResponse; }; | ||
buf = Buffer.from(''); | ||
@@ -258,2 +261,6 @@ serverResponse.write = function (data, encoding) { | ||
}; | ||
if (request.method === 'HEAD') { | ||
completeProxyResponse(null, proxyResponse.statusCode || http_status_codes_1.default.OK); | ||
return [2 /*return*/]; | ||
} | ||
// as the response is ending, we parse the current response body which is JSON, then | ||
@@ -260,0 +267,0 @@ // render the app using that JSON, but return HTML to the final response. |
{ | ||
"name": "@sitecore-jss/sitecore-jss-proxy", | ||
"version": "12.0.0", | ||
"version": "13.0.0", | ||
"description": "Proxy middleware for express.js server.", | ||
@@ -27,3 +27,4 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"http-proxy-middleware": "^0.19.0", | ||
"http-proxy-middleware": "^0.20.0", | ||
"http-status-codes": "^1.3.2", | ||
"set-cookie-parser": "^2.2.1" | ||
@@ -33,15 +34,15 @@ }, | ||
"@types/chai": "^4.1.6", | ||
"@types/http-proxy-middleware": "^0.17.5", | ||
"@types/http-proxy-middleware": "^0.19.3", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.0", | ||
"@types/set-cookie-parser": "^0.0.3", | ||
"@types/node": "^12.7.11", | ||
"@types/set-cookie-parser": "^0.0.5", | ||
"chai": "^4.2.0", | ||
"del-cli": "^1.1.0", | ||
"mocha": "^5.2.0", | ||
"del-cli": "^3.0.0", | ||
"mocha": "^6.2.1", | ||
"sinon": "^7.0.0", | ||
"ts-node": "^7.0.1", | ||
"ts-node": "^8.4.1", | ||
"typescript": "^3.1.3" | ||
}, | ||
"types": "types/index.d.ts", | ||
"gitHead": "2f4820efddf4454eeee58ed1b2cc251969efdf5b" | ||
"gitHead": "74452d5eaf9046673a8d437a545ad4739fadc8bc" | ||
} |
/// <reference types="node" /> | ||
import { ClientRequest, IncomingMessage, ServerResponse } from 'http'; | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
import { Config as HttpProxyConfig } from 'http-proxy-middleware'; | ||
@@ -35,9 +35,9 @@ import { RenderResponse } from './RenderResponse'; | ||
/** Enables transforming SSR'ed HTML after it is rendered, i.e. to replace paths. */ | ||
transformSSRContent?: (response: RenderResponse, request: ClientRequest, serverResponse: ServerResponse) => Promise<string>; | ||
transformSSRContent?: (response: RenderResponse, request: IncomingMessage, serverResponse: ServerResponse) => Promise<string>; | ||
/** Hook to fill the SSR viewBag object; if you're customizing the viewBag in Sitecore integrated SSR mode, do the same here. */ | ||
createViewBag?: (request: ClientRequest, response: ServerResponse, proxyResponse: IncomingMessage, layoutServiceData: any) => Promise<object>; | ||
createViewBag?: (request: IncomingMessage, response: ServerResponse, proxyResponse: IncomingMessage, layoutServiceData: any) => Promise<object>; | ||
/** Hook to alter HTTP headers in a custom way. */ | ||
setHeaders?: (request: ClientRequest, response: ServerResponse, proxyResponse: IncomingMessage) => void; | ||
setHeaders?: (request: IncomingMessage, response: ServerResponse, proxyResponse: IncomingMessage) => void; | ||
/** Responses from the proxy greater than this size (in bytes) are rejected. */ | ||
maxResponseSizeBytes?: number; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
40921
524
3
+ Addedhttp-status-codes@^1.3.2
+ Addedbraces@3.0.3(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedhttp-proxy-middleware@0.20.0(transitive)
+ Addedhttp-status-codes@1.4.0(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedto-regex-range@5.0.1(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-proxy-middleware@0.19.2(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)