@promster/fastify 7.0.7 → 9.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,3 +1,4 @@
1
- import { plugin, getRequestRecorder, signalIsUp, signalIsNotUp } from './plugin';
1
+ import { type TPromsterOptions, plugin, getRequestRecorder, signalIsUp, signalIsNotUp } from "./plugin/index.js";
2
2
  import { getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, timing } from '@promster/metrics';
3
- export { plugin, getRequestRecorder, signalIsUp, signalIsNotUp, getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, timing, };
3
+ export { type TPromsterOptions, plugin, getRequestRecorder, signalIsUp, signalIsNotUp, getSummary, getContentType, Prometheus, defaultRegister, defaultNormalizers, timing, };
4
+ export * from '@promster/types';
@@ -1,2 +1,2 @@
1
- import { plugin, getRequestRecorder, signalIsUp, signalIsNotUp } from './plugin';
2
- export { plugin, signalIsUp, signalIsNotUp, getRequestRecorder };
1
+ import { type TPromsterOptions, plugin, getRequestRecorder, signalIsUp, signalIsNotUp } from "./plugin.js";
2
+ export { type TPromsterOptions, plugin, signalIsUp, signalIsNotUp, getRequestRecorder, };
@@ -1,9 +1,13 @@
1
- import type { TPromsterOptions } from '@promster/types';
2
- import type { TRequestRecorder } from '@promster/metrics';
3
- import type { FastifyRequest } from 'fastify';
1
+ import { type TOptionalPromsterOptions, type TLabelValues } from '@promster/types';
2
+ import { type TRequestRecorder } from '@promster/metrics';
3
+ import { type FastifyInstance, type FastifyRequest, type FastifyReply } from 'fastify';
4
4
  declare const extractPath: (req: FastifyRequest) => string;
5
5
  declare const getRequestRecorder: () => TRequestRecorder;
6
6
  declare const signalIsUp: () => void;
7
7
  declare const signalIsNotUp: () => void;
8
- declare const plugin: import("fastify").FastifyPluginAsync<TPromsterOptions, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault>;
8
+ type TSkipFunction = <TRequest extends FastifyRequest, TResponse extends FastifyReply>(_req: TRequest, _res: TResponse, _labels: TLabelValues) => boolean;
9
+ export type TPromsterOptions = TOptionalPromsterOptions & {
10
+ skip?: TSkipFunction;
11
+ };
12
+ declare const plugin: (fastify: FastifyInstance, options: TPromsterOptions) => Promise<void>;
9
13
  export { plugin, getRequestRecorder, signalIsUp, signalIsNotUp, extractPath };
@@ -1 +1,2 @@
1
1
  export * from "./declarations/src/index";
2
+ //# sourceMappingURL=promster-fastify.cjs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promster-fastify.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var fastifyPlugin = require('fastify-plugin');
6
6
  var merge = require('merge-options');
7
7
  var metrics = require('@promster/metrics');
8
+ var types = require('@promster/types');
8
9
 
9
10
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
11
 
@@ -13,7 +14,7 @@ var merge__default = /*#__PURE__*/_interopDefault(merge);
13
14
 
14
15
  var pkg = {
15
16
  name: "@promster/fastify",
16
- version: "7.0.7",
17
+ version: "9.0.0",
17
18
  description: "Fastify server integrations of promster",
18
19
  main: "dist/promster-fastify.cjs.js",
19
20
  typings: "dist/promster-fastify.cjs.d.ts",
@@ -29,8 +30,8 @@ var pkg = {
29
30
  access: "public"
30
31
  },
31
32
  engines: {
32
- node: ">=14",
33
- npm: ">=6"
33
+ node: ">=16",
34
+ npm: ">=8"
34
35
  },
35
36
  repository: {
36
37
  type: "git",
@@ -49,13 +50,15 @@ var pkg = {
49
50
  "prometheus"
50
51
  ],
51
52
  dependencies: {
52
- "@promster/metrics": "^9.1.6",
53
+ "@promster/metrics": "^11.0.0",
54
+ "@promster/types": "^5.0.0",
53
55
  "fastify-plugin": "^4.4.0",
54
56
  "merge-options": "3.0.4",
55
- "parse-prometheus-text-format": "1.1.1"
57
+ "parse-prometheus-text-format": "1.1.1",
58
+ "@promster/server": "workspace:*"
56
59
  },
57
60
  devDependencies: {
58
- fastify: "4.10.2"
61
+ fastify: "4.22.1"
59
62
  }
60
63
  };
61
64
 
@@ -82,7 +85,9 @@ const signalIsNotUp = () => {
82
85
  });
83
86
  };
84
87
  const createPlugin = async (fastify, options) => {
85
- const allDefaultedOptions = merge__default["default"](metrics.createHttpMetrics.defaultOptions, metrics.createGcMetrics.defaultOptions, metrics.createRequestRecorder.defaultOptions, metrics.createGcObserver.defaultOptions, metrics.defaultNormalizers, options);
88
+ const allDefaultedOptions = merge__default["default"](metrics.createHttpMetrics.defaultOptions, metrics.createGcMetrics.defaultOptions, metrics.createRequestRecorder.defaultOptions,
89
+ // @ts-expect-error
90
+ metrics.createGcObserver.defaultOptions, metrics.defaultNormalizers, options);
86
91
  const shouldSkipMetricsByEnvironment = metrics.skipMetricsInEnvironment(allDefaultedOptions);
87
92
  const httpMetrics = metrics.createHttpMetrics(allDefaultedOptions);
88
93
  const gcMetrics = metrics.createGcMetrics(allDefaultedOptions);
@@ -107,6 +112,7 @@ const createPlugin = async (fastify, options) => {
107
112
  req: request,
108
113
  res: reply
109
114
  }),
115
+ // eslint-disable-next-line camelcase
110
116
  status_code: allDefaultedOptions.normalizeStatusCode(reply.statusCode, {
111
117
  req: request,
112
118
  res: reply
@@ -162,3 +168,9 @@ exports.getRequestRecorder = getRequestRecorder;
162
168
  exports.plugin = plugin;
163
169
  exports.signalIsNotUp = signalIsNotUp;
164
170
  exports.signalIsUp = signalIsUp;
171
+ Object.keys(types).forEach(function (k) {
172
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
173
+ enumerable: true,
174
+ get: function () { return types[k]; }
175
+ });
176
+ });
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var fastifyPlugin = require('fastify-plugin');
6
6
  var merge = require('merge-options');
7
7
  var metrics = require('@promster/metrics');
8
+ var types = require('@promster/types');
8
9
 
9
10
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
10
11
 
@@ -13,7 +14,7 @@ var merge__default = /*#__PURE__*/_interopDefault(merge);
13
14
 
14
15
  var pkg = {
15
16
  name: "@promster/fastify",
16
- version: "7.0.7",
17
+ version: "9.0.0",
17
18
  description: "Fastify server integrations of promster",
18
19
  main: "dist/promster-fastify.cjs.js",
19
20
  typings: "dist/promster-fastify.cjs.d.ts",
@@ -29,8 +30,8 @@ var pkg = {
29
30
  access: "public"
30
31
  },
31
32
  engines: {
32
- node: ">=14",
33
- npm: ">=6"
33
+ node: ">=16",
34
+ npm: ">=8"
34
35
  },
35
36
  repository: {
36
37
  type: "git",
@@ -49,13 +50,15 @@ var pkg = {
49
50
  "prometheus"
50
51
  ],
51
52
  dependencies: {
52
- "@promster/metrics": "^9.1.6",
53
+ "@promster/metrics": "^11.0.0",
54
+ "@promster/types": "^5.0.0",
53
55
  "fastify-plugin": "^4.4.0",
54
56
  "merge-options": "3.0.4",
55
- "parse-prometheus-text-format": "1.1.1"
57
+ "parse-prometheus-text-format": "1.1.1",
58
+ "@promster/server": "workspace:*"
56
59
  },
57
60
  devDependencies: {
58
- fastify: "4.10.2"
61
+ fastify: "4.22.1"
59
62
  }
60
63
  };
61
64
 
@@ -82,7 +85,9 @@ const signalIsNotUp = () => {
82
85
  });
83
86
  };
84
87
  const createPlugin = async (fastify, options) => {
85
- const allDefaultedOptions = merge__default["default"](metrics.createHttpMetrics.defaultOptions, metrics.createGcMetrics.defaultOptions, metrics.createRequestRecorder.defaultOptions, metrics.createGcObserver.defaultOptions, metrics.defaultNormalizers, options);
88
+ const allDefaultedOptions = merge__default["default"](metrics.createHttpMetrics.defaultOptions, metrics.createGcMetrics.defaultOptions, metrics.createRequestRecorder.defaultOptions,
89
+ // @ts-expect-error
90
+ metrics.createGcObserver.defaultOptions, metrics.defaultNormalizers, options);
86
91
  const shouldSkipMetricsByEnvironment = metrics.skipMetricsInEnvironment(allDefaultedOptions);
87
92
  const httpMetrics = metrics.createHttpMetrics(allDefaultedOptions);
88
93
  const gcMetrics = metrics.createGcMetrics(allDefaultedOptions);
@@ -107,6 +112,7 @@ const createPlugin = async (fastify, options) => {
107
112
  req: request,
108
113
  res: reply
109
114
  }),
115
+ // eslint-disable-next-line camelcase
110
116
  status_code: allDefaultedOptions.normalizeStatusCode(reply.statusCode, {
111
117
  req: request,
112
118
  res: reply
@@ -162,3 +168,9 @@ exports.getRequestRecorder = getRequestRecorder;
162
168
  exports.plugin = plugin;
163
169
  exports.signalIsNotUp = signalIsNotUp;
164
170
  exports.signalIsUp = signalIsUp;
171
+ Object.keys(types).forEach(function (k) {
172
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
173
+ enumerable: true,
174
+ get: function () { return types[k]; }
175
+ });
176
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promster/fastify",
3
- "version": "7.0.7",
3
+ "version": "9.0.0",
4
4
  "description": "Fastify server integrations of promster",
5
5
  "main": "dist/promster-fastify.cjs.js",
6
6
  "typings": "dist/promster-fastify.cjs.d.ts",
@@ -16,8 +16,8 @@
16
16
  "access": "public"
17
17
  },
18
18
  "engines": {
19
- "node": ">=14",
20
- "npm": ">=6"
19
+ "node": ">=16",
20
+ "npm": ">=8"
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
@@ -36,12 +36,14 @@
36
36
  "prometheus"
37
37
  ],
38
38
  "dependencies": {
39
- "@promster/metrics": "^9.1.6",
39
+ "@promster/metrics": "^11.0.0",
40
+ "@promster/types": "^5.0.0",
40
41
  "fastify-plugin": "^4.4.0",
41
42
  "merge-options": "3.0.4",
42
- "parse-prometheus-text-format": "1.1.1"
43
+ "parse-prometheus-text-format": "1.1.1",
44
+ "@promster/server": "9.0.0"
43
45
  },
44
46
  "devDependencies": {
45
- "fastify": "4.10.2"
47
+ "fastify": "4.22.1"
46
48
  }
47
- }
49
+ }