@stainlessdev/xray-express 0.1.0-branch.bg-publish-to-npm.18b1cb1
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/index.cjs +57 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createEmitter: () => import_xray_core.createEmitter,
|
|
24
|
+
createExpressMiddleware: () => createExpressMiddleware
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_xray_core = require("@stainlessdev/xray-core");
|
|
28
|
+
var import_xray_node = require("@stainlessdev/xray-node");
|
|
29
|
+
function createExpressMiddleware(xray, options) {
|
|
30
|
+
return (req, res, next) => {
|
|
31
|
+
const wrapped = (0, import_xray_node.wrapHttpHandler)(
|
|
32
|
+
() => {
|
|
33
|
+
next();
|
|
34
|
+
},
|
|
35
|
+
xray,
|
|
36
|
+
{
|
|
37
|
+
...options,
|
|
38
|
+
onRequest: (ctx) => {
|
|
39
|
+
req.xray = ctx;
|
|
40
|
+
res.locals ?? (res.locals = {});
|
|
41
|
+
res.locals.xray = ctx;
|
|
42
|
+
options?.onRequest?.(ctx);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
const result = wrapped(req, res);
|
|
47
|
+
if (result && typeof result.catch === "function") {
|
|
48
|
+
void result.catch(next);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
createEmitter,
|
|
55
|
+
createExpressMiddleware
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { RequestHandler } from 'express';\nimport type { XrayEmitter, XrayContext } from '@stainlessdev/xray-core';\nimport { createEmitter } from '@stainlessdev/xray-core';\nimport { wrapHttpHandler, type WrapOptions } from '@stainlessdev/xray-node';\n\nexport { createEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n} from '@stainlessdev/xray-core';\nexport type { WrapOptions } from '@stainlessdev/xray-node';\n\nexport function createExpressMiddleware(xray: XrayEmitter, options?: WrapOptions): RequestHandler {\n return (req, res, next) => {\n const wrapped = wrapHttpHandler(\n () => {\n next();\n },\n xray,\n {\n ...options,\n onRequest: (ctx: XrayContext) => {\n (req as typeof req & { xray?: XrayContext }).xray = ctx;\n (res as typeof res & { locals?: Record<string, unknown> }).locals ??= {};\n (res.locals as { xray?: XrayContext }).xray = ctx;\n options?.onRequest?.(ctx);\n },\n },\n );\n\n const result = wrapped(req, res);\n if (result && typeof (result as Promise<void>).catch === 'function') {\n void (result as Promise<void>).catch(next);\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,uBAA8B;AAC9B,uBAAkD;AAa3C,SAAS,wBAAwB,MAAmB,SAAuC;AAChG,SAAO,CAAC,KAAK,KAAK,SAAS;AACzB,UAAM,cAAU;AAAA,MACd,MAAM;AACJ,aAAK;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,WAAW,CAAC,QAAqB;AAC/B,UAAC,IAA4C,OAAO;AACpD,UAAC,IAA0D,WAA1D,IAA0D,SAAW,CAAC;AACvE,UAAC,IAAI,OAAkC,OAAO;AAC9C,mBAAS,YAAY,GAAG;AAAA,QAC1B;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,QAAQ,KAAK,GAAG;AAC/B,QAAI,UAAU,OAAQ,OAAyB,UAAU,YAAY;AACnE,WAAM,OAAyB,MAAM,IAAI;AAAA,IAC3C;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
import { XrayEmitter } from '@stainlessdev/xray-core';
|
|
3
|
+
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, createEmitter } from '@stainlessdev/xray-core';
|
|
4
|
+
import { WrapOptions } from '@stainlessdev/xray-node';
|
|
5
|
+
export { WrapOptions } from '@stainlessdev/xray-node';
|
|
6
|
+
|
|
7
|
+
declare function createExpressMiddleware(xray: XrayEmitter, options?: WrapOptions): RequestHandler;
|
|
8
|
+
|
|
9
|
+
export { createExpressMiddleware };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RequestHandler } from 'express';
|
|
2
|
+
import { XrayEmitter } from '@stainlessdev/xray-core';
|
|
3
|
+
export { CaptureConfig, RedactionConfig, RequestLog, XrayConfig, XrayContext, XrayEmitter, createEmitter } from '@stainlessdev/xray-core';
|
|
4
|
+
import { WrapOptions } from '@stainlessdev/xray-node';
|
|
5
|
+
export { WrapOptions } from '@stainlessdev/xray-node';
|
|
6
|
+
|
|
7
|
+
declare function createExpressMiddleware(xray: XrayEmitter, options?: WrapOptions): RequestHandler;
|
|
8
|
+
|
|
9
|
+
export { createExpressMiddleware };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { createEmitter } from "@stainlessdev/xray-core";
|
|
3
|
+
import { wrapHttpHandler } from "@stainlessdev/xray-node";
|
|
4
|
+
function createExpressMiddleware(xray, options) {
|
|
5
|
+
return (req, res, next) => {
|
|
6
|
+
const wrapped = wrapHttpHandler(
|
|
7
|
+
() => {
|
|
8
|
+
next();
|
|
9
|
+
},
|
|
10
|
+
xray,
|
|
11
|
+
{
|
|
12
|
+
...options,
|
|
13
|
+
onRequest: (ctx) => {
|
|
14
|
+
req.xray = ctx;
|
|
15
|
+
res.locals ?? (res.locals = {});
|
|
16
|
+
res.locals.xray = ctx;
|
|
17
|
+
options?.onRequest?.(ctx);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
const result = wrapped(req, res);
|
|
22
|
+
if (result && typeof result.catch === "function") {
|
|
23
|
+
void result.catch(next);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
createEmitter,
|
|
29
|
+
createExpressMiddleware
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { RequestHandler } from 'express';\nimport type { XrayEmitter, XrayContext } from '@stainlessdev/xray-core';\nimport { createEmitter } from '@stainlessdev/xray-core';\nimport { wrapHttpHandler, type WrapOptions } from '@stainlessdev/xray-node';\n\nexport { createEmitter };\nexport type {\n CaptureConfig,\n RedactionConfig,\n RequestLog,\n XrayConfig,\n XrayContext,\n XrayEmitter,\n} from '@stainlessdev/xray-core';\nexport type { WrapOptions } from '@stainlessdev/xray-node';\n\nexport function createExpressMiddleware(xray: XrayEmitter, options?: WrapOptions): RequestHandler {\n return (req, res, next) => {\n const wrapped = wrapHttpHandler(\n () => {\n next();\n },\n xray,\n {\n ...options,\n onRequest: (ctx: XrayContext) => {\n (req as typeof req & { xray?: XrayContext }).xray = ctx;\n (res as typeof res & { locals?: Record<string, unknown> }).locals ??= {};\n (res.locals as { xray?: XrayContext }).xray = ctx;\n options?.onRequest?.(ctx);\n },\n },\n );\n\n const result = wrapped(req, res);\n if (result && typeof (result as Promise<void>).catch === 'function') {\n void (result as Promise<void>).catch(next);\n }\n };\n}\n"],"mappings":";AAEA,SAAS,qBAAqB;AAC9B,SAAS,uBAAyC;AAa3C,SAAS,wBAAwB,MAAmB,SAAuC;AAChG,SAAO,CAAC,KAAK,KAAK,SAAS;AACzB,UAAM,UAAU;AAAA,MACd,MAAM;AACJ,aAAK;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,WAAW,CAAC,QAAqB;AAC/B,UAAC,IAA4C,OAAO;AACpD,UAAC,IAA0D,WAA1D,IAA0D,SAAW,CAAC;AACvE,UAAC,IAAI,OAAkC,OAAO;AAC9C,mBAAS,YAAY,GAAG;AAAA,QAC1B;AAAA,MACF;AAAA,IACF;AAEA,UAAM,SAAS,QAAQ,KAAK,GAAG;AAC/B,QAAI,UAAU,OAAQ,OAAyB,UAAU,YAAY;AACnE,WAAM,OAAyB,MAAM,IAAI;AAAA,IAC3C;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stainlessdev/xray-express",
|
|
3
|
+
"version": "0.1.0-branch.bg-publish-to-npm.18b1cb1",
|
|
4
|
+
"description": "Express integration for Stainless X-ray request logging",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@stainlessdev/xray-core": "0.1.0-branch.bg-publish-to-npm.18b1cb1",
|
|
24
|
+
"@stainlessdev/xray-node": "0.1.0-branch.bg-publish-to-npm.18b1cb1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@opentelemetry/api": "^1.9.0",
|
|
28
|
+
"@opentelemetry/core": "^2.2.0",
|
|
29
|
+
"@opentelemetry/otlp-transformer": "^0.208.0",
|
|
30
|
+
"@opentelemetry/resources": "^2.2.0",
|
|
31
|
+
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
32
|
+
"@opentelemetry/semantic-conventions": "^1.29.0",
|
|
33
|
+
"@types/express": "^5.0.0",
|
|
34
|
+
"@types/node": "^20.11.0",
|
|
35
|
+
"express": "^5.2.1",
|
|
36
|
+
"oxlint": "^1.39.0",
|
|
37
|
+
"tsup": "^8.0.0",
|
|
38
|
+
"tsx": "^4.19.0",
|
|
39
|
+
"typescript": "^5.4.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@opentelemetry/api": "^1.9.0",
|
|
43
|
+
"@opentelemetry/core": "^2.2.0",
|
|
44
|
+
"@opentelemetry/otlp-transformer": "^0.208.0",
|
|
45
|
+
"@opentelemetry/resources": "^2.2.0",
|
|
46
|
+
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
47
|
+
"@opentelemetry/semantic-conventions": "^1.29.0",
|
|
48
|
+
"express": ">=5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=20"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup",
|
|
55
|
+
"test": "tsx --test test/*.test.ts",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"lint": "oxlint",
|
|
58
|
+
"clean": "rm -rf dist"
|
|
59
|
+
}
|
|
60
|
+
}
|