@interopio/gateway-server 0.8.0-beta → 0.8.1-beta.0
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/changelog.md +9 -0
- package/dist/index.cjs +123 -92
- package/dist/index.cjs.map +3 -3
- package/dist/index.js +123 -92
- package/dist/index.js.map +3 -3
- package/dist/metrics/publisher/rest.cjs +13 -1
- package/dist/metrics/publisher/rest.cjs.map +3 -3
- package/dist/metrics/publisher/rest.js +14 -2
- package/dist/metrics/publisher/rest.js.map +2 -2
- package/dist/web/test.js +11 -5
- package/dist/web/test.js.map +2 -2
- package/package.json +1 -1
- package/types/web/server.d.ts +1 -0
package/changelog.md
CHANGED
|
@@ -2,7 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
# Change Log
|
|
4
4
|
|
|
5
|
+
## 0.8.1-beta.0 (2025-08-04)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- `setRawStatusCode` in `ServerHttpResponse` to set the raw status code
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- rest metrics publisher on node 24 should use undici CookieAgent
|
|
12
|
+
|
|
5
13
|
## 0.8.0-beta (2025-08-02)
|
|
14
|
+
|
|
6
15
|
### Added
|
|
7
16
|
- web test client `@interopio/gateway-server/web/test`
|
|
8
17
|
- interop.io developer license agreement
|
package/dist/index.cjs
CHANGED
|
@@ -393,6 +393,118 @@ var MapHttpHeaders = class extends Map {
|
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
|
|
396
|
+
// src/http/status.ts
|
|
397
|
+
var DefaultHttpStatusCode = class {
|
|
398
|
+
#value;
|
|
399
|
+
constructor(value) {
|
|
400
|
+
this.#value = value;
|
|
401
|
+
}
|
|
402
|
+
get value() {
|
|
403
|
+
return this.#value;
|
|
404
|
+
}
|
|
405
|
+
toString() {
|
|
406
|
+
return this.#value.toString();
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
var HttpStatus = class _HttpStatus {
|
|
410
|
+
static CONTINUE = new _HttpStatus(100, "Continue");
|
|
411
|
+
static SWITCHING_PROTOCOLS = new _HttpStatus(101, "Switching Protocols");
|
|
412
|
+
// 2xx Success
|
|
413
|
+
static OK = new _HttpStatus(200, "OK");
|
|
414
|
+
static CREATED = new _HttpStatus(201, "Created");
|
|
415
|
+
static ACCEPTED = new _HttpStatus(202, "Accepted");
|
|
416
|
+
static NON_AUTHORITATIVE_INFORMATION = new _HttpStatus(203, "Non-Authoritative Information");
|
|
417
|
+
static NO_CONTENT = new _HttpStatus(204, "No Content");
|
|
418
|
+
static RESET_CONTENT = new _HttpStatus(205, "Reset Content");
|
|
419
|
+
static PARTIAL_CONTENT = new _HttpStatus(206, "Partial Content");
|
|
420
|
+
static MULTI_STATUS = new _HttpStatus(207, "Multi-Status");
|
|
421
|
+
static IM_USED = new _HttpStatus(226, "IM Used");
|
|
422
|
+
// 3xx Redirection
|
|
423
|
+
static MULTIPLE_CHOICES = new _HttpStatus(300, "Multiple Choices");
|
|
424
|
+
static MOVED_PERMANENTLY = new _HttpStatus(301, "Moved Permanently");
|
|
425
|
+
// 4xx Client Error
|
|
426
|
+
static BAD_REQUEST = new _HttpStatus(400, "Bad Request");
|
|
427
|
+
static UNAUTHORIZED = new _HttpStatus(401, "Unauthorized");
|
|
428
|
+
static FORBIDDEN = new _HttpStatus(403, "Forbidden");
|
|
429
|
+
static NOT_FOUND = new _HttpStatus(404, "Not Found");
|
|
430
|
+
static METHOD_NOT_ALLOWED = new _HttpStatus(405, "Method Not Allowed");
|
|
431
|
+
static NOT_ACCEPTABLE = new _HttpStatus(406, "Not Acceptable");
|
|
432
|
+
static PROXY_AUTHENTICATION_REQUIRED = new _HttpStatus(407, "Proxy Authentication Required");
|
|
433
|
+
static REQUEST_TIMEOUT = new _HttpStatus(408, "Request Timeout");
|
|
434
|
+
static CONFLICT = new _HttpStatus(409, "Conflict");
|
|
435
|
+
static GONE = new _HttpStatus(410, "Gone");
|
|
436
|
+
static LENGTH_REQUIRED = new _HttpStatus(411, "Length Required");
|
|
437
|
+
static PRECONDITION_FAILED = new _HttpStatus(412, "Precondition Failed");
|
|
438
|
+
static PAYLOAD_TOO_LARGE = new _HttpStatus(413, "Payload Too Large");
|
|
439
|
+
static URI_TOO_LONG = new _HttpStatus(414, "URI Too Long");
|
|
440
|
+
static UNSUPPORTED_MEDIA_TYPE = new _HttpStatus(415, "Unsupported Media Type");
|
|
441
|
+
static EXPECTATION_FAILED = new _HttpStatus(417, "Expectation Failed");
|
|
442
|
+
static IM_A_TEAPOT = new _HttpStatus(418, "I'm a teapot");
|
|
443
|
+
static TOO_EARLY = new _HttpStatus(425, "Too Early");
|
|
444
|
+
static UPGRADE_REQUIRED = new _HttpStatus(426, "Upgrade Required");
|
|
445
|
+
static PRECONDITION_REQUIRED = new _HttpStatus(428, "Precondition Required");
|
|
446
|
+
static TOO_MANY_REQUESTS = new _HttpStatus(429, "Too Many Requests");
|
|
447
|
+
static REQUEST_HEADER_FIELDS_TOO_LARGE = new _HttpStatus(431, "Request Header Fields Too Large");
|
|
448
|
+
static UNAVAILABLE_FOR_LEGAL_REASONS = new _HttpStatus(451, "Unavailable For Legal Reasons");
|
|
449
|
+
// 5xx Server Error
|
|
450
|
+
static INTERNAL_SERVER_ERROR = new _HttpStatus(500, "Internal Server Error");
|
|
451
|
+
static NOT_IMPLEMENTED = new _HttpStatus(501, "Not Implemented");
|
|
452
|
+
static BAD_GATEWAY = new _HttpStatus(502, "Bad Gateway");
|
|
453
|
+
static SERVICE_UNAVAILABLE = new _HttpStatus(503, "Service Unavailable");
|
|
454
|
+
static GATEWAY_TIMEOUT = new _HttpStatus(504, "Gateway Timeout");
|
|
455
|
+
static HTTP_VERSION_NOT_SUPPORTED = new _HttpStatus(505, "HTTP Version Not Supported");
|
|
456
|
+
static VARIANT_ALSO_NEGOTIATES = new _HttpStatus(506, "Variant Also Negotiates");
|
|
457
|
+
static INSUFFICIENT_STORAGE = new _HttpStatus(507, "Insufficient Storage");
|
|
458
|
+
static LOOP_DETECTED = new _HttpStatus(508, "Loop Detected");
|
|
459
|
+
static NOT_EXTENDED = new _HttpStatus(510, "Not Extended");
|
|
460
|
+
static NETWORK_AUTHENTICATION_REQUIRED = new _HttpStatus(511, "Network Authentication Required");
|
|
461
|
+
static #VALUES = [];
|
|
462
|
+
static {
|
|
463
|
+
Object.keys(_HttpStatus).filter((key) => key !== "VALUES" && key !== "resolve").forEach((key) => {
|
|
464
|
+
const value = _HttpStatus[key];
|
|
465
|
+
if (value instanceof _HttpStatus) {
|
|
466
|
+
Object.defineProperty(value, "name", { enumerable: true, value: key, writable: false });
|
|
467
|
+
_HttpStatus.#VALUES.push(value);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
static resolve(code) {
|
|
472
|
+
for (const status of _HttpStatus.#VALUES) {
|
|
473
|
+
if (status.value === code) {
|
|
474
|
+
return status;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
#value;
|
|
479
|
+
#phrase;
|
|
480
|
+
constructor(value, phrase) {
|
|
481
|
+
this.#value = value;
|
|
482
|
+
this.#phrase = phrase;
|
|
483
|
+
}
|
|
484
|
+
get value() {
|
|
485
|
+
return this.#value;
|
|
486
|
+
}
|
|
487
|
+
get phrase() {
|
|
488
|
+
return this.#phrase;
|
|
489
|
+
}
|
|
490
|
+
toString() {
|
|
491
|
+
return `${this.#value} ${this["name"]}`;
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
function httpStatusCode(value) {
|
|
495
|
+
if (typeof value === "number") {
|
|
496
|
+
if (value < 100 || value > 999) {
|
|
497
|
+
throw new Error(`status code ${value} should be in range 100-999`);
|
|
498
|
+
}
|
|
499
|
+
const status = HttpStatus.resolve(value);
|
|
500
|
+
if (status !== void 0) {
|
|
501
|
+
return status;
|
|
502
|
+
}
|
|
503
|
+
return new DefaultHttpStatusCode(value);
|
|
504
|
+
}
|
|
505
|
+
return value;
|
|
506
|
+
}
|
|
507
|
+
|
|
396
508
|
// src/server/exchange.ts
|
|
397
509
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
398
510
|
var ExtendedHttpIncomingMessage = class extends import_node_http.default.IncomingMessage {
|
|
@@ -429,6 +541,9 @@ var AbstractServerHttpResponse = class extends AbstractHttpResponse {
|
|
|
429
541
|
return true;
|
|
430
542
|
}
|
|
431
543
|
}
|
|
544
|
+
setRawStatusCode(statusCode) {
|
|
545
|
+
return this.setStatusCode(statusCode === void 0 ? void 0 : httpStatusCode(statusCode));
|
|
546
|
+
}
|
|
432
547
|
get statusCode() {
|
|
433
548
|
return this.#statusCode;
|
|
434
549
|
}
|
|
@@ -810,20 +925,23 @@ var ServerHttpResponseDecorator = class _ServerHttpResponseDecorator {
|
|
|
810
925
|
return this.#delegate;
|
|
811
926
|
}
|
|
812
927
|
setStatusCode(statusCode) {
|
|
813
|
-
return this
|
|
928
|
+
return this.delegate.setStatusCode(statusCode);
|
|
929
|
+
}
|
|
930
|
+
setRawStatusCode(statusCode) {
|
|
931
|
+
return this.delegate.setRawStatusCode(statusCode);
|
|
814
932
|
}
|
|
815
933
|
get statusCode() {
|
|
816
|
-
return this
|
|
934
|
+
return this.delegate.statusCode;
|
|
817
935
|
}
|
|
818
936
|
get cookies() {
|
|
819
|
-
return this
|
|
937
|
+
return this.delegate.cookies;
|
|
820
938
|
}
|
|
821
939
|
addCookie(cookie) {
|
|
822
|
-
this
|
|
940
|
+
this.delegate.addCookie(cookie);
|
|
823
941
|
return this;
|
|
824
942
|
}
|
|
825
943
|
async end() {
|
|
826
|
-
return await this
|
|
944
|
+
return await this.delegate.end();
|
|
827
945
|
}
|
|
828
946
|
async body(body) {
|
|
829
947
|
return await this.#delegate.body(body);
|
|
@@ -1326,93 +1444,6 @@ async function configure(app, config, routes) {
|
|
|
1326
1444
|
await app(configurer, config);
|
|
1327
1445
|
}
|
|
1328
1446
|
|
|
1329
|
-
// src/http/status.ts
|
|
1330
|
-
var HttpStatus = class _HttpStatus {
|
|
1331
|
-
static CONTINUE = new _HttpStatus(100, "Continue");
|
|
1332
|
-
static SWITCHING_PROTOCOLS = new _HttpStatus(101, "Switching Protocols");
|
|
1333
|
-
// 2xx Success
|
|
1334
|
-
static OK = new _HttpStatus(200, "OK");
|
|
1335
|
-
static CREATED = new _HttpStatus(201, "Created");
|
|
1336
|
-
static ACCEPTED = new _HttpStatus(202, "Accepted");
|
|
1337
|
-
static NON_AUTHORITATIVE_INFORMATION = new _HttpStatus(203, "Non-Authoritative Information");
|
|
1338
|
-
static NO_CONTENT = new _HttpStatus(204, "No Content");
|
|
1339
|
-
static RESET_CONTENT = new _HttpStatus(205, "Reset Content");
|
|
1340
|
-
static PARTIAL_CONTENT = new _HttpStatus(206, "Partial Content");
|
|
1341
|
-
static MULTI_STATUS = new _HttpStatus(207, "Multi-Status");
|
|
1342
|
-
static IM_USED = new _HttpStatus(226, "IM Used");
|
|
1343
|
-
// 3xx Redirection
|
|
1344
|
-
static MULTIPLE_CHOICES = new _HttpStatus(300, "Multiple Choices");
|
|
1345
|
-
static MOVED_PERMANENTLY = new _HttpStatus(301, "Moved Permanently");
|
|
1346
|
-
// 4xx Client Error
|
|
1347
|
-
static BAD_REQUEST = new _HttpStatus(400, "Bad Request");
|
|
1348
|
-
static UNAUTHORIZED = new _HttpStatus(401, "Unauthorized");
|
|
1349
|
-
static FORBIDDEN = new _HttpStatus(403, "Forbidden");
|
|
1350
|
-
static NOT_FOUND = new _HttpStatus(404, "Not Found");
|
|
1351
|
-
static METHOD_NOT_ALLOWED = new _HttpStatus(405, "Method Not Allowed");
|
|
1352
|
-
static NOT_ACCEPTABLE = new _HttpStatus(406, "Not Acceptable");
|
|
1353
|
-
static PROXY_AUTHENTICATION_REQUIRED = new _HttpStatus(407, "Proxy Authentication Required");
|
|
1354
|
-
static REQUEST_TIMEOUT = new _HttpStatus(408, "Request Timeout");
|
|
1355
|
-
static CONFLICT = new _HttpStatus(409, "Conflict");
|
|
1356
|
-
static GONE = new _HttpStatus(410, "Gone");
|
|
1357
|
-
static LENGTH_REQUIRED = new _HttpStatus(411, "Length Required");
|
|
1358
|
-
static PRECONDITION_FAILED = new _HttpStatus(412, "Precondition Failed");
|
|
1359
|
-
static PAYLOAD_TOO_LARGE = new _HttpStatus(413, "Payload Too Large");
|
|
1360
|
-
static URI_TOO_LONG = new _HttpStatus(414, "URI Too Long");
|
|
1361
|
-
static UNSUPPORTED_MEDIA_TYPE = new _HttpStatus(415, "Unsupported Media Type");
|
|
1362
|
-
static EXPECTATION_FAILED = new _HttpStatus(417, "Expectation Failed");
|
|
1363
|
-
static IM_A_TEAPOT = new _HttpStatus(418, "I'm a teapot");
|
|
1364
|
-
static TOO_EARLY = new _HttpStatus(425, "Too Early");
|
|
1365
|
-
static UPGRADE_REQUIRED = new _HttpStatus(426, "Upgrade Required");
|
|
1366
|
-
static PRECONDITION_REQUIRED = new _HttpStatus(428, "Precondition Required");
|
|
1367
|
-
static TOO_MANY_REQUESTS = new _HttpStatus(429, "Too Many Requests");
|
|
1368
|
-
static REQUEST_HEADER_FIELDS_TOO_LARGE = new _HttpStatus(431, "Request Header Fields Too Large");
|
|
1369
|
-
static UNAVAILABLE_FOR_LEGAL_REASONS = new _HttpStatus(451, "Unavailable For Legal Reasons");
|
|
1370
|
-
// 5xx Server Error
|
|
1371
|
-
static INTERNAL_SERVER_ERROR = new _HttpStatus(500, "Internal Server Error");
|
|
1372
|
-
static NOT_IMPLEMENTED = new _HttpStatus(501, "Not Implemented");
|
|
1373
|
-
static BAD_GATEWAY = new _HttpStatus(502, "Bad Gateway");
|
|
1374
|
-
static SERVICE_UNAVAILABLE = new _HttpStatus(503, "Service Unavailable");
|
|
1375
|
-
static GATEWAY_TIMEOUT = new _HttpStatus(504, "Gateway Timeout");
|
|
1376
|
-
static HTTP_VERSION_NOT_SUPPORTED = new _HttpStatus(505, "HTTP Version Not Supported");
|
|
1377
|
-
static VARIANT_ALSO_NEGOTIATES = new _HttpStatus(506, "Variant Also Negotiates");
|
|
1378
|
-
static INSUFFICIENT_STORAGE = new _HttpStatus(507, "Insufficient Storage");
|
|
1379
|
-
static LOOP_DETECTED = new _HttpStatus(508, "Loop Detected");
|
|
1380
|
-
static NOT_EXTENDED = new _HttpStatus(510, "Not Extended");
|
|
1381
|
-
static NETWORK_AUTHENTICATION_REQUIRED = new _HttpStatus(511, "Network Authentication Required");
|
|
1382
|
-
static #VALUES = [];
|
|
1383
|
-
static {
|
|
1384
|
-
Object.keys(_HttpStatus).filter((key) => key !== "VALUES" && key !== "resolve").forEach((key) => {
|
|
1385
|
-
const value = _HttpStatus[key];
|
|
1386
|
-
if (value instanceof _HttpStatus) {
|
|
1387
|
-
Object.defineProperty(value, "name", { enumerable: true, value: key, writable: false });
|
|
1388
|
-
_HttpStatus.#VALUES.push(value);
|
|
1389
|
-
}
|
|
1390
|
-
});
|
|
1391
|
-
}
|
|
1392
|
-
static resolve(code) {
|
|
1393
|
-
for (const status of _HttpStatus.#VALUES) {
|
|
1394
|
-
if (status.value === code) {
|
|
1395
|
-
return status;
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
#value;
|
|
1400
|
-
#phrase;
|
|
1401
|
-
constructor(value, phrase) {
|
|
1402
|
-
this.#value = value;
|
|
1403
|
-
this.#phrase = phrase;
|
|
1404
|
-
}
|
|
1405
|
-
get value() {
|
|
1406
|
-
return this.#value;
|
|
1407
|
-
}
|
|
1408
|
-
get phrase() {
|
|
1409
|
-
return this.#phrase;
|
|
1410
|
-
}
|
|
1411
|
-
toString() {
|
|
1412
|
-
return `${this.#value} ${this["name"]}`;
|
|
1413
|
-
}
|
|
1414
|
-
};
|
|
1415
|
-
|
|
1416
1447
|
// src/server/cors.ts
|
|
1417
1448
|
var import_gateway5 = require("@interopio/gateway");
|
|
1418
1449
|
function isSameOrigin(request) {
|