@lucaapp/service-utils 1.52.0 → 1.53.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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deprecatedEndpoint = void 0;
|
|
4
|
+
const deprecatedEndpoint = (request, response, next) => {
|
|
5
|
+
response.deprecated = 1;
|
|
6
|
+
return next();
|
|
7
|
+
};
|
|
8
|
+
exports.deprecatedEndpoint = deprecatedEndpoint;
|
|
@@ -7,7 +7,7 @@ exports.responseTimeMiddleware = void 0;
|
|
|
7
7
|
const response_time_1 = __importDefault(require("response-time"));
|
|
8
8
|
const normalizePath_1 = __importDefault(require("../../utils/normalizePath"));
|
|
9
9
|
const metrics_1 = require("../metrics");
|
|
10
|
-
const labelNames = ['method', 'statusCode', 'path', 'host'];
|
|
10
|
+
const labelNames = ['method', 'statusCode', 'path', 'host', 'deprecated'];
|
|
11
11
|
const requestDuration = new metrics_1.metricsClient.Histogram({
|
|
12
12
|
name: 'http_request_duration_seconds',
|
|
13
13
|
help: 'A histogram of the HTTP request durations in seconds.',
|
|
@@ -22,7 +22,7 @@ const responseSize = new metrics_1.metricsClient.Histogram({
|
|
|
22
22
|
});
|
|
23
23
|
exports.responseTimeMiddleware = (0, response_time_1.default)((request, response, time) => {
|
|
24
24
|
const { method, route, baseUrl, originalUrl, headers: { host }, } = request;
|
|
25
|
-
const { statusCode, _contentLength } = response;
|
|
25
|
+
const { statusCode, _contentLength, deprecated } = response;
|
|
26
26
|
if (!route)
|
|
27
27
|
return;
|
|
28
28
|
const path = `${baseUrl || (0, normalizePath_1.default)(originalUrl, route.path)}${baseUrl ? route.path : ''}`.toLowerCase();
|
|
@@ -31,6 +31,7 @@ exports.responseTimeMiddleware = (0, response_time_1.default)((request, response
|
|
|
31
31
|
path,
|
|
32
32
|
statusCode,
|
|
33
33
|
host,
|
|
34
|
+
deprecated,
|
|
34
35
|
};
|
|
35
36
|
requestDuration.observe(labels, time / 1000);
|
|
36
37
|
responseSize.observe(labels, _contentLength || 0);
|