@jaypie/express 1.2.4-rc7 → 1.2.4-rc8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +56 -7
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +56 -7
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -1290,6 +1290,55 @@ function summarizeResponse(res, extras) {
|
|
|
1290
1290
|
|
|
1291
1291
|
// Cast logger to extended interface for runtime features not in type definitions
|
|
1292
1292
|
const logger$1 = logger$2.log;
|
|
1293
|
+
//
|
|
1294
|
+
//
|
|
1295
|
+
// Helpers - Safe response methods to bypass dd-trace interception
|
|
1296
|
+
//
|
|
1297
|
+
/**
|
|
1298
|
+
* Check if response is a Lambda mock response with direct _headers access.
|
|
1299
|
+
*/
|
|
1300
|
+
function isLambdaMockResponse(res) {
|
|
1301
|
+
return res._headers instanceof Map;
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Safely send a JSON response, avoiding dd-trace interception.
|
|
1305
|
+
* For Lambda mock responses, directly sets headers and writes to stream.
|
|
1306
|
+
*/
|
|
1307
|
+
function safeSendJson(res, statusCode, data) {
|
|
1308
|
+
if (isLambdaMockResponse(res)) {
|
|
1309
|
+
// Direct access for Lambda mock responses - bypasses dd-trace
|
|
1310
|
+
res._headers.set("content-type", "application/json");
|
|
1311
|
+
res.statusCode = statusCode;
|
|
1312
|
+
res.end(JSON.stringify(data));
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
// Fall back to standard Express methods for real responses
|
|
1316
|
+
res.status(statusCode).json(data);
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Safely send a response body, avoiding dd-trace interception.
|
|
1320
|
+
* For Lambda mock responses, directly writes to stream.
|
|
1321
|
+
*/
|
|
1322
|
+
function safeSend(res, statusCode, body) {
|
|
1323
|
+
if (isLambdaMockResponse(res)) {
|
|
1324
|
+
// Direct access for Lambda mock responses - bypasses dd-trace
|
|
1325
|
+
res.statusCode = statusCode;
|
|
1326
|
+
if (body !== undefined) {
|
|
1327
|
+
res.end(body);
|
|
1328
|
+
}
|
|
1329
|
+
else {
|
|
1330
|
+
res.end();
|
|
1331
|
+
}
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
// Fall back to standard Express methods for real responses
|
|
1335
|
+
if (body !== undefined) {
|
|
1336
|
+
res.status(statusCode).send(body);
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
res.status(statusCode).send();
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1293
1342
|
function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
1294
1343
|
/* eslint-enable no-redeclare */
|
|
1295
1344
|
let handler;
|
|
@@ -1506,30 +1555,30 @@ function expressHandler(handlerOrOptions, optionsOrHandler) {
|
|
|
1506
1555
|
if (typeof response === "object") {
|
|
1507
1556
|
if (typeof response.json ===
|
|
1508
1557
|
"function") {
|
|
1509
|
-
res
|
|
1558
|
+
safeSendJson(res, status, response.json());
|
|
1510
1559
|
}
|
|
1511
1560
|
else {
|
|
1512
|
-
res
|
|
1561
|
+
safeSendJson(res, status, response);
|
|
1513
1562
|
}
|
|
1514
1563
|
}
|
|
1515
1564
|
else if (typeof response === "string") {
|
|
1516
1565
|
try {
|
|
1517
|
-
res
|
|
1566
|
+
safeSendJson(res, status, JSON.parse(response));
|
|
1518
1567
|
}
|
|
1519
1568
|
catch {
|
|
1520
|
-
res
|
|
1569
|
+
safeSend(res, status, response);
|
|
1521
1570
|
}
|
|
1522
1571
|
}
|
|
1523
1572
|
else if (response === true) {
|
|
1524
|
-
res
|
|
1573
|
+
safeSend(res, kit.HTTP.CODE.CREATED);
|
|
1525
1574
|
}
|
|
1526
1575
|
else {
|
|
1527
|
-
res
|
|
1576
|
+
safeSend(res, status, response);
|
|
1528
1577
|
}
|
|
1529
1578
|
}
|
|
1530
1579
|
else {
|
|
1531
1580
|
// No response
|
|
1532
|
-
res
|
|
1581
|
+
safeSend(res, kit.HTTP.CODE.NO_CONTENT);
|
|
1533
1582
|
}
|
|
1534
1583
|
}
|
|
1535
1584
|
else {
|