@vue-storefront/middleware
Advanced tools
Comparing version 2.3.4 to 2.4.0
@@ -119,2 +119,21 @@ 'use strict'; | ||
var getAgnosticStatusCode = function (obj) { | ||
var searchedKeys = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
searchedKeys[_i - 1] = arguments[_i]; | ||
} | ||
if (!obj || typeof obj !== 'object') | ||
return; | ||
for (var _a = 0, _b = Object.keys(obj); _a < _b.length; _a++) { | ||
var key = _b[_a]; | ||
if (searchedKeys.includes(key)) { | ||
return obj[key]; | ||
} | ||
var statusCode = getAgnosticStatusCode.apply(void 0, __spreadArray([obj[key]], searchedKeys)); | ||
if (statusCode) { | ||
return statusCode; | ||
} | ||
} | ||
}; | ||
var app = express(); | ||
@@ -151,3 +170,3 @@ app.use(express.json()); | ||
error_1 = _c.sent(); | ||
res.status(500); | ||
res.status(getAgnosticStatusCode(error_1, 'status', 'statusCode') || 500); | ||
res.send(error_1); | ||
@@ -154,0 +173,0 @@ return [3 /*break*/, 4]; |
@@ -113,2 +113,21 @@ import express from 'express'; | ||
var getAgnosticStatusCode = function (obj) { | ||
var searchedKeys = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
searchedKeys[_i - 1] = arguments[_i]; | ||
} | ||
if (!obj || typeof obj !== 'object') | ||
return; | ||
for (var _a = 0, _b = Object.keys(obj); _a < _b.length; _a++) { | ||
var key = _b[_a]; | ||
if (searchedKeys.includes(key)) { | ||
return obj[key]; | ||
} | ||
var statusCode = getAgnosticStatusCode.apply(void 0, __spreadArray([obj[key]], searchedKeys)); | ||
if (statusCode) { | ||
return statusCode; | ||
} | ||
} | ||
}; | ||
var app = express(); | ||
@@ -145,3 +164,3 @@ app.use(express.json()); | ||
error_1 = _c.sent(); | ||
res.status(500); | ||
res.status(getAgnosticStatusCode(error_1, 'status', 'statusCode') || 500); | ||
res.send(error_1); | ||
@@ -148,0 +167,0 @@ return [3 /*break*/, 4]; |
{ | ||
"name": "@vue-storefront/middleware", | ||
"version": "2.3.4", | ||
"version": "2.4.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.cjs.js", |
@@ -7,2 +7,3 @@ import express, { Request, Response, Express } from 'express'; | ||
import { registerIntegrations } from './integrations'; | ||
import getAgnosticStatusCode from './helpers/getAgnosticStatusCode'; | ||
@@ -46,4 +47,3 @@ const app = express(); | ||
} catch (error) { | ||
res.status(500); | ||
res.status(getAgnosticStatusCode(error, 'status', 'statusCode') || 500); | ||
res.send(error); | ||
@@ -50,0 +50,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
75809
516
13