@biorate/nestjs-tools 1.151.1 → 1.152.1
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 +10 -0
- package/dist/src/middlewares/proxy-middleware.js +13 -10
- package/dist/src/middlewares/proxy-middleware.js.map +1 -1
- package/dist/src/middlewares/response-time-middleware.js +7 -9
- package/dist/src/middlewares/response-time-middleware.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/middlewares/proxy-middleware.ts +15 -7
- package/src/middlewares/response-time-middleware.ts +11 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.152.1](https://github.com/biorate/core/compare/v1.152.0...v1.152.1) (2025-09-05)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- axios-prometheus, nsetjs-tools - hystogram metrics bucket config ([976c666](https://github.com/biorate/core/commit/976c666a56d7fca2ed93f9978f473d83d3251282))
|
|
11
|
+
|
|
12
|
+
# [1.152.0](https://github.com/biorate/core/compare/v1.151.1...v1.152.0) (2025-09-01)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @biorate/nestjs-tools
|
|
15
|
+
|
|
6
16
|
## [1.151.1](https://github.com/biorate/core/compare/v1.151.0...v1.151.1) (2025-08-15)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
|
@@ -15,6 +15,7 @@ const http_proxy_middleware_1 = require("http-proxy-middleware");
|
|
|
15
15
|
const common_1 = require("@nestjs/common");
|
|
16
16
|
const prometheus_1 = require("@biorate/prometheus");
|
|
17
17
|
const tools_1 = require("@biorate/tools");
|
|
18
|
+
const inversion_1 = require("@biorate/inversion");
|
|
18
19
|
let ProxyPrometheusMiddleware = class ProxyPrometheusMiddleware {
|
|
19
20
|
static create(options) {
|
|
20
21
|
return new this(options).handler;
|
|
@@ -22,6 +23,13 @@ let ProxyPrometheusMiddleware = class ProxyPrometheusMiddleware {
|
|
|
22
23
|
constructor(options = {}) {
|
|
23
24
|
this.time = new WeakMap();
|
|
24
25
|
const { onProxyReq, onProxyRes } = (0, lodash_1.pick)(options, 'onProxyReq', 'onProxyRes');
|
|
26
|
+
this.histogram = new prometheus_1.Histogram({
|
|
27
|
+
name: 'http_proxy_server_requests_seconds',
|
|
28
|
+
help: 'Http proxy server requests seconds bucket',
|
|
29
|
+
labelNames: ['method', 'uri', 'status'],
|
|
30
|
+
buckets: this.config.get('ProxyPrometheusMiddleware.histogram.buckets', [0.005, 0.01, 0.02, 0.05, 0.1, 0.3, 0.5, 1, 2, 3, 5, 10]),
|
|
31
|
+
registers: [prometheus_1.Prometheus.registry],
|
|
32
|
+
});
|
|
25
33
|
this.handler = (0, http_proxy_middleware_1.createProxyMiddleware)(Object.assign(Object.assign({}, (0, lodash_1.omit)(options, 'onProxyReq', 'onProxyRes')), { onProxyReq: (proxyReq, req, res, options) => {
|
|
26
34
|
this.time.set(req, { time: tools_1.time.diff() });
|
|
27
35
|
return onProxyReq === null || onProxyReq === void 0 ? void 0 : onProxyReq(proxyReq, req, res, options);
|
|
@@ -45,23 +53,18 @@ let ProxyPrometheusMiddleware = class ProxyPrometheusMiddleware {
|
|
|
45
53
|
} }));
|
|
46
54
|
}
|
|
47
55
|
};
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, inversion_1.inject)(inversion_1.Types.Config),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], ProxyPrometheusMiddleware.prototype, "config", void 0);
|
|
48
60
|
__decorate([
|
|
49
61
|
(0, prometheus_1.counter)({
|
|
50
62
|
name: 'http_proxy_server_requests_seconds_count',
|
|
51
63
|
help: 'Http proxy server requests count',
|
|
52
64
|
labelNames: ['method', 'uri', 'status'],
|
|
53
65
|
}),
|
|
54
|
-
__metadata("design:type",
|
|
66
|
+
__metadata("design:type", prometheus_1.Counter)
|
|
55
67
|
], ProxyPrometheusMiddleware.prototype, "counter", void 0);
|
|
56
|
-
__decorate([
|
|
57
|
-
(0, prometheus_1.histogram)({
|
|
58
|
-
name: 'http_proxy_server_requests_seconds',
|
|
59
|
-
help: 'Http proxy server requests seconds bucket',
|
|
60
|
-
labelNames: ['method', 'uri', 'status'],
|
|
61
|
-
buckets: [0.005, 0.01, 0.02, 0.05, 0.1, 0.3, 0.5, 1, 2, 3, 5, 10],
|
|
62
|
-
}),
|
|
63
|
-
__metadata("design:type", Object)
|
|
64
|
-
], ProxyPrometheusMiddleware.prototype, "histogram", void 0);
|
|
65
68
|
ProxyPrometheusMiddleware = __decorate([
|
|
66
69
|
(0, common_1.Injectable)(),
|
|
67
70
|
__metadata("design:paramtypes", [Object])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy-middleware.js","sourceRoot":"","sources":["../../../src/middlewares/proxy-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mCAAoC;AAEpC,iEAA8D;AAE9D,2CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"proxy-middleware.js","sourceRoot":"","sources":["../../../src/middlewares/proxy-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mCAAoC;AAEpC,iEAA8D;AAE9D,2CAA4C;AAC5C,oDAA8E;AAC9E,0CAAsC;AACtC,kDAAmD;AAGnD,IACa,yBAAyB,GADtC,MACa,yBAAyB;IAgB7B,MAAM,CAAC,MAAM,CAAC,OAAiB;QACpC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;IACnC,CAAC;IAED,YAAoB,UAAmB,EAAE;QANjC,SAAI,GAAG,IAAI,OAAO,EAAmC,CAAC;QAO5D,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,IAAA,aAAI,EAAC,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC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,CAAC,SAAS;qBACX,MAAM,CAAC;oBACN,MAAM,EAAE,GAAG,CAAC,MAAM;oBAClB,GAAG,EAAE,GAAG,CAAC,OAAO;oBAChB,MAAM,EAAE,GAAG,CAAC,UAAU;iBACvB,CAAC;qBACD,OAAO,CAAC,YAAI,CAAC,IAAI,CAAC,IAAK,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;gBACzC,OAAO,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YAC1C,CAAC,IACD,CAAC;IACL,CAAC;CACF,CAAA;AA9D+B;IAA7B,IAAA,kBAAM,EAAC,iBAAK,CAAC,MAAM,CAAC;;yDAAyB;AAOtC;IALP,IAAA,oBAAO,EAAC;QACP,IAAI,EAAE,0CAA0C;QAChD,IAAI,EAAE,kCAAkC;QACxC,UAAU,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC;KACxC,CAAC;8BACe,oBAAO;0DAAC;AARd,yBAAyB;IADrC,IAAA,mBAAU,GAAE;;GACA,yBAAyB,CA+DrC;AA/DY,8DAAyB"}
|
|
@@ -21,6 +21,13 @@ let ResponseTimeMiddleware = class ResponseTimeMiddleware {
|
|
|
21
21
|
this.suffix = this.config.get('app.middleware.ResponseTimeMiddleware.suffix', true);
|
|
22
22
|
this.header = this.config.get('app.middleware.ResponseTimeMiddleware.header', 'x-response-time');
|
|
23
23
|
this.digits = this.config.get('app.middleware.ResponseTimeMiddleware.digits', 3);
|
|
24
|
+
this.histogram = new prometheus_1.Histogram({
|
|
25
|
+
name: 'http_server_requests_seconds',
|
|
26
|
+
help: 'Http server requests seconds bucket',
|
|
27
|
+
labelNames: ['method', 'uri', 'status'],
|
|
28
|
+
buckets: this.config.get('ResponseTimeMiddleware.histogram.buckets', [0.005, 0.01, 0.02, 0.05, 0.1, 0.3, 0.5, 1, 2, 3, 5, 10]),
|
|
29
|
+
registers: [prometheus_1.Prometheus.registry],
|
|
30
|
+
});
|
|
24
31
|
}
|
|
25
32
|
use(req, res, next) {
|
|
26
33
|
const diff = tools_1.time.diff();
|
|
@@ -47,15 +54,6 @@ __decorate([
|
|
|
47
54
|
(0, inversion_1.inject)(inversion_1.Types.Config),
|
|
48
55
|
__metadata("design:type", Object)
|
|
49
56
|
], ResponseTimeMiddleware.prototype, "config", void 0);
|
|
50
|
-
__decorate([
|
|
51
|
-
(0, prometheus_1.histogram)({
|
|
52
|
-
name: 'http_server_requests_seconds',
|
|
53
|
-
help: 'Http server requests seconds bucket',
|
|
54
|
-
labelNames: ['method', 'uri', 'status'],
|
|
55
|
-
buckets: [0.005, 0.01, 0.02, 0.05, 0.1, 0.3, 0.5, 1, 2, 3, 5, 10],
|
|
56
|
-
}),
|
|
57
|
-
__metadata("design:type", Object)
|
|
58
|
-
], ResponseTimeMiddleware.prototype, "histogram", void 0);
|
|
59
57
|
ResponseTimeMiddleware = __decorate([
|
|
60
58
|
(0, common_1.Injectable)(),
|
|
61
59
|
__metadata("design:paramtypes", [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-time-middleware.js","sourceRoot":"","sources":["../../../src/middlewares/response-time-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAAwC;AACxC,2CAA4D;AAC5D,kDAAmD;AAEnD,
|
|
1
|
+
{"version":3,"file":"response-time-middleware.js","sourceRoot":"","sources":["../../../src/middlewares/response-time-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAAwC;AACxC,2CAA4D;AAC5D,kDAAmD;AAEnD,oDAA4D;AAE5D,0CAAsC;AACtC,kDAAoD;AAEpD,IACa,sBAAsB,GADnC,MACa,sBAAsB;IAWjC;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAC3B,8CAA8C,EAC9C,IAAI,CACL,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAC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