From 6c82468fa260fd15440c584e70f90b41ef85ecfc Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Tue, 16 Apr 2024 07:58:33 +0200 Subject: [PATCH] fix: correctly get and set top level `contentType` property --- CHANGELOG.md | 4 +++- index.js | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bbb8a624..7dc1f5aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,12 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Changed -- Enable `bun.js` by catching `NotImplemented` error (Fixes [#570](https://github.com/siimon/prom-client/issues/570)) +- Correctly read and set `contentType` top level export ### Added +- Enable `bun.js` by catching `NotImplemented` error (Fixes [#570](https://github.com/siimon/prom-client/issues/570)) + [unreleased]: https://github.com/siimon/prom-client/compare/v15.1.0...HEAD ## [15.1.1] - 2024-03-26 diff --git a/index.js b/index.js index 7f6e167a..2683d481 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,14 @@ exports.register = require('./lib/registry').globalRegistry; exports.Registry = require('./lib/registry'); -exports.contentType = require('./lib/registry').globalRegistry.contentType; +Object.defineProperty(exports, 'contentType', { + configurable: false, + enumerable: true, + get: () => exports.register.contentType, + set: value => { + exports.register.setContentType(value); + }, +}); exports.prometheusContentType = require('./lib/registry').PROMETHEUS_CONTENT_TYPE; exports.openMetricsContentType =