@promster/hapi 6.1.0 → 7.0.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.
@@ -1,6 +1,6 @@
1
- import type { TPromsterOptions } from '@promster/types';
2
- import type { Server } from '@hapi/hapi';
3
- import { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp } from './plugin';
4
- import { getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers } from '@promster/metrics';
5
- declare const instrument: (server: Server, options: TPromsterOptions) => Promise<void>;
6
- export { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp, getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, instrument, };
1
+ import type { TPromsterOptions } from '@promster/types';
2
+ import type { Server } from '@hapi/hapi';
3
+ import { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp } from './plugin';
4
+ import { getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers } from '@promster/metrics';
5
+ declare const instrument: (server: Server, options: TPromsterOptions) => Promise<void>;
6
+ export { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp, getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, instrument, };
@@ -1,2 +1,2 @@
1
- import { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp } from './plugin';
2
- export { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp };
1
+ import { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp } from './plugin';
2
+ export { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp };
@@ -1,12 +1,12 @@
1
- import type { TPromsterOptions } from '@promster/types';
2
- import type { TRequestRecorder } from '@promster/metrics';
3
- import type { Plugin } from '@hapi/hapi';
4
- declare const getRequestRecorder: () => TRequestRecorder;
5
- declare const signalIsUp: () => void;
6
- declare const signalIsNotUp: () => void;
7
- declare const getAreServerEventsSupported: (actualVersion: string) => boolean;
8
- declare const getDoesResponseNeedInvocation: (actualVersion: string) => boolean;
9
- declare const createPlugin: ({ options: pluginOptions, }?: {
10
- options?: TPromsterOptions;
11
- }) => Plugin<unknown>;
12
- export { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp, getAreServerEventsSupported, getDoesResponseNeedInvocation, };
1
+ import type { TPromsterOptions } from '@promster/types';
2
+ import type { TRequestRecorder } from '@promster/metrics';
3
+ import type { Plugin } from '@hapi/hapi';
4
+ declare const getRequestRecorder: () => TRequestRecorder;
5
+ declare const signalIsUp: () => void;
6
+ declare const signalIsNotUp: () => void;
7
+ declare const getAreServerEventsSupported: (actualVersion: string) => boolean;
8
+ declare const getDoesResponseNeedInvocation: (actualVersion: string) => boolean;
9
+ declare const createPlugin: ({ options: pluginOptions, }?: {
10
+ options?: TPromsterOptions;
11
+ }) => Plugin<unknown>;
12
+ export { createPlugin, getRequestRecorder, signalIsUp, signalIsNotUp, getAreServerEventsSupported, getDoesResponseNeedInvocation, };
@@ -13,7 +13,7 @@ var merge__default = /*#__PURE__*/_interopDefault(merge);
13
13
 
14
14
  var pkg = {
15
15
  name: "@promster/hapi",
16
- version: "6.1.0",
16
+ version: "7.0.0",
17
17
  description: "Hapi server integrations of promster",
18
18
  main: "dist/promster-hapi.cjs.js",
19
19
  typings: "dist/promster-hapi.cjs.d.ts",
@@ -31,8 +31,8 @@ var pkg = {
31
31
  access: "public"
32
32
  },
33
33
  engines: {
34
- node: ">=12",
35
- npm: ">=6.9.0"
34
+ node: ">=14",
35
+ npm: ">=6"
36
36
  },
37
37
  repository: {
38
38
  type: "git",
@@ -50,26 +50,21 @@ var pkg = {
50
50
  "prometheus"
51
51
  ],
52
52
  dependencies: {
53
- "@promster/metrics": "^7.0.0",
53
+ "@promster/metrics": "^8.0.0",
54
54
  "merge-options": "3.0.4",
55
55
  semver: "7.3.5",
56
56
  tslib: "2.3.1"
57
57
  },
58
58
  devDependencies: {
59
59
  "@hapi/boom": "9.1.4",
60
- "@promster/types": "^3.1.0",
60
+ "@promster/types": "^3.1.5",
61
61
  "@types/hapi__hapi": "20.0.9"
62
62
  }
63
63
  };
64
64
 
65
65
  const extractPath = request => request.route.path.replace(/\?/g, '');
66
- /* eslint-disable @typescript-eslint/no-unnecessary-type-arguments */
67
66
 
68
-
69
- // eslint-disable-next-line no-undef
70
67
  const isBoomResponse = response => response.isBoom;
71
- /* eslint-enable @typescript-eslint/no-unnecessary-type-arguments */
72
-
73
68
 
74
69
  const extractStatusCode = request => {
75
70
  const {
@@ -112,17 +107,17 @@ const signalIsNotUp = () => {
112
107
  });
113
108
  };
114
109
 
115
- const getAreServerEventsSupported = actualVersion => Boolean(actualVersion && semver__default['default'].satisfies(actualVersion, '>= 17.0.0'));
110
+ const getAreServerEventsSupported = actualVersion => Boolean(actualVersion && semver__default["default"].satisfies(actualVersion, '>= 17.0.0'));
116
111
 
117
- const getDoesResponseNeedInvocation = actualVersion => Boolean(actualVersion && semver__default['default'].satisfies(actualVersion, '< 17.0.0'));
112
+ const getDoesResponseNeedInvocation = actualVersion => Boolean(actualVersion && semver__default["default"].satisfies(actualVersion, '< 17.0.0'));
118
113
 
119
114
  const createPlugin = ({
120
115
  options: pluginOptions
121
116
  } = {
122
117
  options: undefined
123
118
  }) => {
124
- const defaultedOptions = merge__default['default'](metrics.createMetricTypes.defaultOptions, metrics.createRequestRecorder.defaultOptions, metrics.defaultNormalizers, pluginOptions);
125
- const shouldSkipMetricsByEnvironment = defaultedOptions.detectKubernetes === true && !metrics.isRunningInKubernetes();
119
+ const defaultedOptions = merge__default["default"](metrics.createMetricTypes.defaultOptions, metrics.createRequestRecorder.defaultOptions, metrics.defaultNormalizers, pluginOptions);
120
+ const shouldSkipMetricsByEnvironment = defaultedOptions.detectKubernetes && !metrics.isRunningInKubernetes();
126
121
  const metricTypes = metrics.createMetricTypes(defaultedOptions);
127
122
  const observeGc = metrics.createGcObserver(metricTypes);
128
123
  recordRequest = metrics.createRequestRecorder(metricTypes, defaultedOptions);
@@ -150,16 +145,16 @@ const createPlugin = ({
150
145
  };
151
146
 
152
147
  const onResponseHandler = (request, response) => {
153
- var _defaultedOptions$get, _defaultedOptions$ski;
148
+ var _defaultedOptions$get, _request$headers$cont, _request$headers, _request$response$hea, _request$response, _request$response$hea2, _defaultedOptions$ski;
154
149
 
155
150
  const labels = Object.assign({}, {
156
151
  path: defaultedOptions.normalizePath(extractPath(request)),
157
152
  method: defaultedOptions.normalizeMethod(request.method),
158
153
  status_code: defaultedOptions.normalizeStatusCode(extractStatusCode(request))
159
154
  }, (_defaultedOptions$get = defaultedOptions.getLabelValues) === null || _defaultedOptions$get === void 0 ? void 0 : _defaultedOptions$get.call(defaultedOptions, request, {}));
160
- const requestContentLength = Number(request.headers['content-length']);
155
+ const requestContentLength = Number((_request$headers$cont = request === null || request === void 0 ? void 0 : (_request$headers = request.headers) === null || _request$headers === void 0 ? void 0 : _request$headers['content-length']) !== null && _request$headers$cont !== void 0 ? _request$headers$cont : 0);
161
156
  const responseContentLength = Number( // @ts-expect-error
162
- request.response.headers['content-length']);
157
+ (_request$response$hea = request === null || request === void 0 ? void 0 : (_request$response = request.response) === null || _request$response === void 0 ? void 0 : (_request$response$hea2 = _request$response.headers) === null || _request$response$hea2 === void 0 ? void 0 : _request$response$hea2['content-length']) !== null && _request$response$hea !== void 0 ? _request$response$hea : 0);
163
158
  const shouldSkipByRequest = (_defaultedOptions$ski = defaultedOptions.skip) === null || _defaultedOptions$ski === void 0 ? void 0 : _defaultedOptions$ski.call(defaultedOptions, request, response, labels);
164
159
 
165
160
  if (!shouldSkipByRequest && !shouldSkipMetricsByEnvironment) {
@@ -171,7 +166,7 @@ const createPlugin = ({
171
166
  }
172
167
 
173
168
  if (doesResponseNeedInvocation) response.continue();
174
- }; // NOTE: This version detection allows us to graceully support both new and old Hapi APIs.
169
+ }; // NOTE: This version detection allows us to gracefully support both new and old Hapi APIs.
175
170
  // This is very hard to type as we would have to import two aliased versions of types.
176
171
 
177
172
 
@@ -209,33 +204,23 @@ const instrument = async (server, options) => server.register(createPlugin({
209
204
 
210
205
  Object.defineProperty(exports, 'Prometheus', {
211
206
  enumerable: true,
212
- get: function () {
213
- return metrics.Prometheus;
214
- }
207
+ get: function () { return metrics.Prometheus; }
215
208
  });
216
209
  Object.defineProperty(exports, 'defaultNormalizers', {
217
210
  enumerable: true,
218
- get: function () {
219
- return metrics.defaultNormalizers;
220
- }
211
+ get: function () { return metrics.defaultNormalizers; }
221
212
  });
222
213
  Object.defineProperty(exports, 'defaultRegister', {
223
214
  enumerable: true,
224
- get: function () {
225
- return metrics.defaultRegister;
226
- }
215
+ get: function () { return metrics.defaultRegister; }
227
216
  });
228
217
  Object.defineProperty(exports, 'getContentType', {
229
218
  enumerable: true,
230
- get: function () {
231
- return metrics.getContentType;
232
- }
219
+ get: function () { return metrics.getContentType; }
233
220
  });
234
221
  Object.defineProperty(exports, 'getSummary', {
235
222
  enumerable: true,
236
- get: function () {
237
- return metrics.getSummary;
238
- }
223
+ get: function () { return metrics.getSummary; }
239
224
  });
240
225
  exports.createPlugin = createPlugin;
241
226
  exports.getRequestRecorder = getRequestRecorder;
@@ -13,7 +13,7 @@ var merge__default = /*#__PURE__*/_interopDefault(merge);
13
13
 
14
14
  var pkg = {
15
15
  name: "@promster/hapi",
16
- version: "6.1.0",
16
+ version: "7.0.0",
17
17
  description: "Hapi server integrations of promster",
18
18
  main: "dist/promster-hapi.cjs.js",
19
19
  typings: "dist/promster-hapi.cjs.d.ts",
@@ -31,8 +31,8 @@ var pkg = {
31
31
  access: "public"
32
32
  },
33
33
  engines: {
34
- node: ">=12",
35
- npm: ">=6.9.0"
34
+ node: ">=14",
35
+ npm: ">=6"
36
36
  },
37
37
  repository: {
38
38
  type: "git",
@@ -50,26 +50,21 @@ var pkg = {
50
50
  "prometheus"
51
51
  ],
52
52
  dependencies: {
53
- "@promster/metrics": "^7.0.0",
53
+ "@promster/metrics": "^8.0.0",
54
54
  "merge-options": "3.0.4",
55
55
  semver: "7.3.5",
56
56
  tslib: "2.3.1"
57
57
  },
58
58
  devDependencies: {
59
59
  "@hapi/boom": "9.1.4",
60
- "@promster/types": "^3.1.0",
60
+ "@promster/types": "^3.1.5",
61
61
  "@types/hapi__hapi": "20.0.9"
62
62
  }
63
63
  };
64
64
 
65
65
  const extractPath = request => request.route.path.replace(/\?/g, '');
66
- /* eslint-disable @typescript-eslint/no-unnecessary-type-arguments */
67
66
 
68
-
69
- // eslint-disable-next-line no-undef
70
67
  const isBoomResponse = response => response.isBoom;
71
- /* eslint-enable @typescript-eslint/no-unnecessary-type-arguments */
72
-
73
68
 
74
69
  const extractStatusCode = request => {
75
70
  const {
@@ -112,17 +107,17 @@ const signalIsNotUp = () => {
112
107
  });
113
108
  };
114
109
 
115
- const getAreServerEventsSupported = actualVersion => Boolean(actualVersion && semver__default['default'].satisfies(actualVersion, '>= 17.0.0'));
110
+ const getAreServerEventsSupported = actualVersion => Boolean(actualVersion && semver__default["default"].satisfies(actualVersion, '>= 17.0.0'));
116
111
 
117
- const getDoesResponseNeedInvocation = actualVersion => Boolean(actualVersion && semver__default['default'].satisfies(actualVersion, '< 17.0.0'));
112
+ const getDoesResponseNeedInvocation = actualVersion => Boolean(actualVersion && semver__default["default"].satisfies(actualVersion, '< 17.0.0'));
118
113
 
119
114
  const createPlugin = ({
120
115
  options: pluginOptions
121
116
  } = {
122
117
  options: undefined
123
118
  }) => {
124
- const defaultedOptions = merge__default['default'](metrics.createMetricTypes.defaultOptions, metrics.createRequestRecorder.defaultOptions, metrics.defaultNormalizers, pluginOptions);
125
- const shouldSkipMetricsByEnvironment = defaultedOptions.detectKubernetes === true && !metrics.isRunningInKubernetes();
119
+ const defaultedOptions = merge__default["default"](metrics.createMetricTypes.defaultOptions, metrics.createRequestRecorder.defaultOptions, metrics.defaultNormalizers, pluginOptions);
120
+ const shouldSkipMetricsByEnvironment = defaultedOptions.detectKubernetes && !metrics.isRunningInKubernetes();
126
121
  const metricTypes = metrics.createMetricTypes(defaultedOptions);
127
122
  const observeGc = metrics.createGcObserver(metricTypes);
128
123
  recordRequest = metrics.createRequestRecorder(metricTypes, defaultedOptions);
@@ -150,16 +145,16 @@ const createPlugin = ({
150
145
  };
151
146
 
152
147
  const onResponseHandler = (request, response) => {
153
- var _defaultedOptions$get, _defaultedOptions$ski;
148
+ var _defaultedOptions$get, _request$headers$cont, _request$headers, _request$response$hea, _request$response, _request$response$hea2, _defaultedOptions$ski;
154
149
 
155
150
  const labels = Object.assign({}, {
156
151
  path: defaultedOptions.normalizePath(extractPath(request)),
157
152
  method: defaultedOptions.normalizeMethod(request.method),
158
153
  status_code: defaultedOptions.normalizeStatusCode(extractStatusCode(request))
159
154
  }, (_defaultedOptions$get = defaultedOptions.getLabelValues) === null || _defaultedOptions$get === void 0 ? void 0 : _defaultedOptions$get.call(defaultedOptions, request, {}));
160
- const requestContentLength = Number(request.headers['content-length']);
155
+ const requestContentLength = Number((_request$headers$cont = request === null || request === void 0 ? void 0 : (_request$headers = request.headers) === null || _request$headers === void 0 ? void 0 : _request$headers['content-length']) !== null && _request$headers$cont !== void 0 ? _request$headers$cont : 0);
161
156
  const responseContentLength = Number( // @ts-expect-error
162
- request.response.headers['content-length']);
157
+ (_request$response$hea = request === null || request === void 0 ? void 0 : (_request$response = request.response) === null || _request$response === void 0 ? void 0 : (_request$response$hea2 = _request$response.headers) === null || _request$response$hea2 === void 0 ? void 0 : _request$response$hea2['content-length']) !== null && _request$response$hea !== void 0 ? _request$response$hea : 0);
163
158
  const shouldSkipByRequest = (_defaultedOptions$ski = defaultedOptions.skip) === null || _defaultedOptions$ski === void 0 ? void 0 : _defaultedOptions$ski.call(defaultedOptions, request, response, labels);
164
159
 
165
160
  if (!shouldSkipByRequest && !shouldSkipMetricsByEnvironment) {
@@ -171,7 +166,7 @@ const createPlugin = ({
171
166
  }
172
167
 
173
168
  if (doesResponseNeedInvocation) response.continue();
174
- }; // NOTE: This version detection allows us to graceully support both new and old Hapi APIs.
169
+ }; // NOTE: This version detection allows us to gracefully support both new and old Hapi APIs.
175
170
  // This is very hard to type as we would have to import two aliased versions of types.
176
171
 
177
172
 
@@ -209,33 +204,23 @@ const instrument = async (server, options) => server.register(createPlugin({
209
204
 
210
205
  Object.defineProperty(exports, 'Prometheus', {
211
206
  enumerable: true,
212
- get: function () {
213
- return metrics.Prometheus;
214
- }
207
+ get: function () { return metrics.Prometheus; }
215
208
  });
216
209
  Object.defineProperty(exports, 'defaultNormalizers', {
217
210
  enumerable: true,
218
- get: function () {
219
- return metrics.defaultNormalizers;
220
- }
211
+ get: function () { return metrics.defaultNormalizers; }
221
212
  });
222
213
  Object.defineProperty(exports, 'defaultRegister', {
223
214
  enumerable: true,
224
- get: function () {
225
- return metrics.defaultRegister;
226
- }
215
+ get: function () { return metrics.defaultRegister; }
227
216
  });
228
217
  Object.defineProperty(exports, 'getContentType', {
229
218
  enumerable: true,
230
- get: function () {
231
- return metrics.getContentType;
232
- }
219
+ get: function () { return metrics.getContentType; }
233
220
  });
234
221
  Object.defineProperty(exports, 'getSummary', {
235
222
  enumerable: true,
236
- get: function () {
237
- return metrics.getSummary;
238
- }
223
+ get: function () { return metrics.getSummary; }
239
224
  });
240
225
  exports.createPlugin = createPlugin;
241
226
  exports.getRequestRecorder = getRequestRecorder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promster/hapi",
3
- "version": "6.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "Hapi server integrations of promster",
5
5
  "main": "dist/promster-hapi.cjs.js",
6
6
  "typings": "dist/promster-hapi.cjs.d.ts",
@@ -17,8 +17,8 @@
17
17
  "access": "public"
18
18
  },
19
19
  "engines": {
20
- "node": ">=12",
21
- "npm": ">=6.9.0"
20
+ "node": ">=14",
21
+ "npm": ">=6"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
@@ -36,14 +36,14 @@
36
36
  "prometheus"
37
37
  ],
38
38
  "dependencies": {
39
- "@promster/metrics": "^7.0.0",
39
+ "@promster/metrics": "^8.0.0",
40
40
  "merge-options": "3.0.4",
41
41
  "semver": "7.3.5",
42
42
  "tslib": "2.3.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@hapi/boom": "9.1.4",
46
- "@promster/types": "^3.1.0",
46
+ "@promster/types": "^3.1.5",
47
47
  "@types/hapi__hapi": "20.0.9"
48
48
  }
49
49
  }
@@ -1,38 +0,0 @@
1
- export const name: string;
2
- export const version: string;
3
- export const description: string;
4
- export const main: string;
5
- export const typings: string;
6
- export const types: string;
7
- export const scripts: {};
8
- export const files: string[];
9
- export namespace publishConfig {
10
- const access: string;
11
- }
12
- export namespace engines {
13
- const node: string;
14
- const npm: string;
15
- }
16
- export namespace repository {
17
- const type: string;
18
- const url: string;
19
- }
20
- export const author: string;
21
- export const license: string;
22
- export namespace bugs {
23
- const url_1: string;
24
- export { url_1 as url };
25
- }
26
- export const homepage: string;
27
- export const keywords: string[];
28
- export const dependencies: {
29
- "@promster/metrics": string;
30
- "merge-options": string;
31
- semver: string;
32
- tslib: string;
33
- };
34
- export const devDependencies: {
35
- "@hapi/boom": string;
36
- "@promster/types": string;
37
- "@types/hapi__hapi": string;
38
- };