@foxford/den 4.0.0 → 4.2.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,8 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
- var _chunkT5QVCXVBcjs = require('./chunk-T5QVCXVB.cjs');
4
-
5
- // src/ops/index.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/ops/index.ts
6
2
  var _http = require('http');
7
3
  var _client = require('@prometheus-io/client');
8
4
 
@@ -11,17 +7,30 @@ var _client = require('@prometheus-io/client');
11
7
 
12
8
  // src/ops/runtime.ts
13
9
  var _cluster = require('cluster'); var _cluster2 = _interopRequireDefault(_cluster);
10
+ var _perf_hooks = require('perf_hooks');
14
11
 
15
12
  function collectRuntime(registry, appName) {
16
13
  registry.setDefaultLabels({ app: appName, process_role: _cluster2.default.isWorker ? "worker" : "main" });
17
14
  _client.collectDefaultMetrics.call(void 0, { register: registry });
15
+ let previousElu = _perf_hooks.performance.eventLoopUtilization();
16
+ new (0, _client.Gauge)({
17
+ aggregator: "max",
18
+ collect() {
19
+ const current = _perf_hooks.performance.eventLoopUtilization();
20
+ this.set(_perf_hooks.performance.eventLoopUtilization(current, previousElu).utilization);
21
+ previousElu = current;
22
+ },
23
+ help: "Event loop utilization since the last scrape; maximum across workers",
24
+ name: "nodejs_eventloop_utilization_ratio",
25
+ registers: [registry]
26
+ });
18
27
  let previousCpu = process.cpuUsage();
19
- let previousTime = performance.now();
28
+ let previousTime = _perf_hooks.performance.now();
20
29
  new (0, _client.Gauge)({
21
30
  aggregator: "sum",
22
31
  collect() {
23
32
  const currentCpu = process.cpuUsage();
24
- const currentTime = performance.now();
33
+ const currentTime = _perf_hooks.performance.now();
25
34
  const elapsed = currentTime - previousTime;
26
35
  this.set(
27
36
  elapsed > 0 ? (currentCpu.user - previousCpu.user + currentCpu.system - previousCpu.system) / (elapsed * 1e3) : 0
@@ -70,8 +79,8 @@ function collectRuntime(registry, appName) {
70
79
  collect() {
71
80
  this.set(process.resourceUsage()[field]);
72
81
  },
73
- help: `Process ${name} since startup`,
74
- name: `process_${name}_total`,
82
+ help: "Process ".concat(name, " since startup"),
83
+ name: "process_".concat(name, "_total"),
75
84
  registers: [registry]
76
85
  });
77
86
  }
@@ -156,64 +165,60 @@ function clusterMetrics(metrics = getProcessMetrics()) {
156
165
  shutdown: () => lifecycle.shutdown()
157
166
  };
158
167
  }
159
- function startOpsServer() {
160
- return _chunkT5QVCXVBcjs.__async.call(void 0, this, arguments, function* (options = {}) {
161
- var _a;
162
- const metrics = (_a = options.metrics) != null ? _a : getProcessMetrics();
163
- const server = _http.createServer.call(void 0, (req, res) => {
164
- var _a2, _b, _c, _d;
165
- const path = (_a2 = req.url) == null ? void 0 : _a2.split("?")[0];
166
- res.setHeader("cache-control", "no-store");
167
- if (req.method !== "GET" || !["/healthz", "/livez", "/metrics"].includes(path != null ? path : "")) {
168
- res.writeHead(404).end();
169
- return;
168
+ async function startOpsServer(options = {}) {
169
+ var _a;
170
+ const metrics = (_a = options.metrics) != null ? _a : getProcessMetrics();
171
+ const server = _http.createServer.call(void 0, (req, res) => {
172
+ var _a2, _b, _c, _d;
173
+ const path = (_a2 = req.url) == null ? void 0 : _a2.split("?")[0];
174
+ res.setHeader("cache-control", "no-store");
175
+ if (req.method !== "GET" || !["/healthz", "/livez", "/metrics"].includes(path != null ? path : "")) {
176
+ res.writeHead(404).end();
177
+ return;
178
+ }
179
+ if (path !== "/metrics") {
180
+ res.writeHead(path === "/livez" && ((_b = options.isLive) == null ? void 0 : _b.call(options)) === false ? 503 : 200, {
181
+ "content-type": "text/plain; charset=utf-8"
182
+ }).end("ok");
183
+ return;
184
+ }
185
+ void ((_d = (_c = options.collect) == null ? void 0 : _c.call(options)) != null ? _d : metrics.registry.metrics()).then((body) => {
186
+ var _a3;
187
+ if (!res.destroyed) {
188
+ res.writeHead(200, { "content-type": (_a3 = options.contentType) != null ? _a3 : metrics.registry.contentType }).end(body);
170
189
  }
171
- if (path !== "/metrics") {
172
- res.writeHead(path === "/livez" && ((_b = options.isLive) == null ? void 0 : _b.call(options)) === false ? 503 : 200, {
173
- "content-type": "text/plain; charset=utf-8"
174
- }).end("ok");
175
- return;
190
+ }).catch(() => {
191
+ if (!res.destroyed) {
192
+ res.writeHead(503).end("metrics unavailable");
176
193
  }
177
- void ((_d = (_c = options.collect) == null ? void 0 : _c.call(options)) != null ? _d : metrics.registry.metrics()).then((body) => {
178
- var _a3;
179
- if (!res.destroyed) {
180
- res.writeHead(200, { "content-type": (_a3 = options.contentType) != null ? _a3 : metrics.registry.contentType }).end(body);
181
- }
182
- }).catch(() => {
183
- if (!res.destroyed) {
184
- res.writeHead(503).end("metrics unavailable");
185
- }
186
- });
187
194
  });
188
- yield new Promise((resolve, reject) => {
189
- var _a2, _b;
190
- server.once("error", reject);
191
- server.listen((_a2 = options.port) != null ? _a2 : 9090, (_b = options.host) != null ? _b : "0.0.0.0", () => {
192
- server.removeListener("error", reject);
193
- resolve();
194
- });
195
+ });
196
+ await new Promise((resolve, reject) => {
197
+ var _a2, _b;
198
+ server.once("error", reject);
199
+ server.listen((_a2 = options.port) != null ? _a2 : 9090, (_b = options.host) != null ? _b : "0.0.0.0", () => {
200
+ server.removeListener("error", reject);
201
+ resolve();
195
202
  });
196
- return server;
197
203
  });
204
+ return server;
198
205
  }
199
- function closeHttpServer(server, timeoutMs = 5e3) {
200
- return _chunkT5QVCXVBcjs.__async.call(void 0, this, null, function* () {
201
- if (!server.listening) {
202
- return;
203
- }
204
- yield new Promise((resolve, reject) => {
205
- const timer = setTimeout(() => server.closeAllConnections(), timeoutMs);
206
- timer.unref();
207
- server.close((error) => {
208
- clearTimeout(timer);
209
- if (error) {
210
- reject(error);
211
- } else {
212
- resolve();
213
- }
214
- });
215
- server.closeIdleConnections();
206
+ async function closeHttpServer(server, timeoutMs = 5e3) {
207
+ if (!server.listening) {
208
+ return;
209
+ }
210
+ await new Promise((resolve, reject) => {
211
+ const timer = setTimeout(() => server.closeAllConnections(), timeoutMs);
212
+ timer.unref();
213
+ server.close((error) => {
214
+ clearTimeout(timer);
215
+ if (error) {
216
+ reject(error);
217
+ } else {
218
+ resolve();
219
+ }
216
220
  });
221
+ server.closeIdleConnections();
217
222
  });
218
223
  }
219
224
 
@@ -14,7 +14,7 @@ function viewAdapterOf(layer) {
14
14
  function adapterOfConfig(config) {
15
15
  if (!isViewAdapter(config.adapter)) {
16
16
  throw new Error(
17
- `den/island: view-\u0441\u043B\u043E\u0439 \xAB${config.name}\xBB \u043E\u0431\u044A\u044F\u0432\u043B\u0435\u043D \u0431\u0435\u0437 \u0430\u0434\u0430\u043F\u0442\u0435\u0440\u0430 \u2014 \u043E\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044F ViewAdapter (type + createIsland + renderIsland + installResolver), \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440 reactAdapter()`
17
+ "den/island: view-\u0441\u043B\u043E\u0439 \xAB".concat(config.name, "\xBB \u043E\u0431\u044A\u044F\u0432\u043B\u0435\u043D \u0431\u0435\u0437 \u0430\u0434\u0430\u043F\u0442\u0435\u0440\u0430 \u2014 ") + "\u043E\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044F ViewAdapter (type + createIsland + renderIsland + installResolver), \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440 reactAdapter()"
18
18
  );
19
19
  }
20
20
  return config.adapter;
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkXOJ2VWX4cjs = require('./chunk-XOJ2VWX4.cjs');
3
+ var _chunkMWDNN7Q4cjs = require('./chunk-MWDNN7Q4.cjs');
4
4
 
5
5
 
6
6
  var _chunk6QV4L6R2cjs = require('./chunk-6QV4L6R2.cjs');
@@ -10,10 +10,6 @@ var _chunk6QV4L6R2cjs = require('./chunk-6QV4L6R2.cjs');
10
10
 
11
11
  var _chunkA6ZPAM6Zcjs = require('./chunk-A6ZPAM6Z.cjs');
12
12
 
13
-
14
-
15
- var _chunkT5QVCXVBcjs = require('./chunk-T5QVCXVB.cjs');
16
-
17
13
  // src/island/document.ts
18
14
  function isDocumentSource(value) {
19
15
  return typeof value === "object" && value !== null && typeof value.describeDocument === "function";
@@ -39,7 +35,7 @@ function installRuntime(container, extensions) {
39
35
  unit.register(container);
40
36
  }
41
37
  installed.push(extension);
42
- ((_a = _chunkA6ZPAM6Zcjs.logger.getLogger("island:runtime")) != null ? _a : _chunkA6ZPAM6Zcjs.logger).debug(`\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043D\u0438\u0435 \u0440\u0430\u043D\u0442\u0430\u0439\u043C\u0430 \xAB${extension.name}\xBB \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u043E`);
38
+ ((_a = _chunkA6ZPAM6Zcjs.logger.getLogger("island:runtime")) != null ? _a : _chunkA6ZPAM6Zcjs.logger).debug("\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043D\u0438\u0435 \u0440\u0430\u043D\u0442\u0430\u0439\u043C\u0430 \xAB".concat(extension.name, "\xBB \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u043E"));
43
39
  }
44
40
  }
45
41
  function bindInstalled(container) {
@@ -120,7 +116,7 @@ function registerIslandParts(container, descriptor, islandLog) {
120
116
  const viewModels = (_b = descriptor.viewModels) != null ? _b : [];
121
117
  const slots = Object.entries((_c = descriptor.slots) != null ? _c : {});
122
118
  islandLog.info(
123
- `\u043E\u0441\u0442\u0440\u043E\u0432: \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440 \u0441\u043E\u0437\u0434\u0430\u043D (units=${descriptor.units.length}, vms=${viewModels.length}, slots=${slots.length})`
119
+ "\u043E\u0441\u0442\u0440\u043E\u0432: \u043A\u043E\u043D\u0442\u0435\u0439\u043D\u0435\u0440 \u0441\u043E\u0437\u0434\u0430\u043D (units=".concat(descriptor.units.length, ", vms=").concat(viewModels.length, ", slots=").concat(slots.length, ")")
124
120
  );
125
121
  for (const unit of descriptor.units) {
126
122
  unit.register(container);
@@ -160,18 +156,16 @@ function hydrateIslandState(container, descriptor, denState) {
160
156
  }
161
157
  }
162
158
  }
163
- function activateIslandViewModels(_0, _1) {
164
- return _chunkT5QVCXVBcjs.__async.call(void 0, this, arguments, function* (container, descriptor, route = EMPTY_ROUTE) {
165
- var _a;
166
- yield Promise.all(
167
- ((_a = descriptor.viewModels) != null ? _a : []).map((vm) => _chunkT5QVCXVBcjs.__async.call(void 0, null, null, function* () {
168
- var _a2;
169
- const instance = container.resolve(vm.token);
170
- _chunkA6ZPAM6Zcjs.unitLogger.call(void 0, container, vm.token.description).debug(`\u0430\u043A\u0442\u0438\u0432\u0430\u0446\u0438\u044F VM (${route.pathname || "\u2014"})`);
171
- yield (_a2 = instance.activate) == null ? void 0 : _a2.call(instance, route);
172
- }))
173
- );
174
- });
159
+ async function activateIslandViewModels(container, descriptor, route = EMPTY_ROUTE) {
160
+ var _a;
161
+ await Promise.all(
162
+ ((_a = descriptor.viewModels) != null ? _a : []).map(async (vm) => {
163
+ var _a2;
164
+ const instance = container.resolve(vm.token);
165
+ _chunkA6ZPAM6Zcjs.unitLogger.call(void 0, container, vm.token.description).debug("\u0430\u043A\u0442\u0438\u0432\u0430\u0446\u0438\u044F VM (".concat(route.pathname || "\u2014", ")"));
166
+ await ((_a2 = instance.activate) == null ? void 0 : _a2.call(instance, route));
167
+ })
168
+ );
175
169
  }
176
170
  function collectIslandState(container, descriptor) {
177
171
  var _a, _b;
@@ -194,10 +188,10 @@ function collectDocumentContribution(container, descriptor) {
194
188
  }
195
189
  const part = instance.describeDocument();
196
190
  if (part.head) {
197
- contribution.head = _chunkT5QVCXVBcjs.__spreadValues.call(void 0, _chunkT5QVCXVBcjs.__spreadValues.call(void 0, {}, contribution.head), part.head);
191
+ contribution.head = { ...contribution.head, ...part.head };
198
192
  }
199
193
  if (part.data) {
200
- contribution.data = _chunkT5QVCXVBcjs.__spreadValues.call(void 0, _chunkT5QVCXVBcjs.__spreadValues.call(void 0, {}, contribution.data), part.data);
194
+ contribution.data = { ...contribution.data, ...part.data };
201
195
  }
202
196
  if (part.assets && contribution.assets === void 0) {
203
197
  contribution.assets = part.assets;
@@ -238,41 +232,39 @@ function setupOnce(descriptor) {
238
232
  }
239
233
  return started;
240
234
  }
241
- function renderApp(descriptor, request) {
242
- return _chunkT5QVCXVBcjs.__async.call(void 0, this, null, function* () {
243
- var _a, _b, _c;
244
- yield setupOnce(descriptor);
245
- const route = {
246
- params: (_a = request.params) != null ? _a : {},
247
- pathname: request.pathname,
248
- search: (_b = request.search) != null ? _b : ""
249
- };
250
- const inputs = islandInputsOf(descriptor, request.inputs);
251
- const container = createIslandContainer(descriptor, { context: request.context, inputs, parent: request.parent });
252
- if (container === null) {
253
- throw new Error(`den/island: \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB${descriptor.name}\xBB \u043D\u0435 \u0441\u043E\u0431\u0440\u0430\u043B\u043E\u0441\u044C \u2014 \u0440\u0435\u043D\u0434\u0435\u0440 \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u0435\u043D`);
235
+ async function renderApp(descriptor, request) {
236
+ var _a, _b, _c;
237
+ await setupOnce(descriptor);
238
+ const route = {
239
+ params: (_a = request.params) != null ? _a : {},
240
+ pathname: request.pathname,
241
+ search: (_b = request.search) != null ? _b : ""
242
+ };
243
+ const inputs = islandInputsOf(descriptor, request.inputs);
244
+ const container = createIslandContainer(descriptor, { context: request.context, inputs, parent: request.parent });
245
+ if (container === null) {
246
+ throw new Error("den/island: \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 \xAB".concat(descriptor.name, "\xBB \u043D\u0435 \u0441\u043E\u0431\u0440\u0430\u043B\u043E\u0441\u044C \u2014 \u0440\u0435\u043D\u0434\u0435\u0440 \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u0435\u043D"));
247
+ }
248
+ try {
249
+ await activateIslandViewModels(container, descriptor, route);
250
+ const contribution = collectDocumentContribution(container, descriptor);
251
+ const { data, head, redirect, status = STATUS_OK } = contribution;
252
+ if (status !== STATUS_OK) {
253
+ return { data, head, html: "", redirect, state: {}, status };
254
254
  }
255
- try {
256
- yield activateIslandViewModels(container, descriptor, route);
257
- const contribution = collectDocumentContribution(container, descriptor);
258
- const { data, head, redirect, status = STATUS_OK } = contribution;
259
- if (status !== STATUS_OK) {
260
- return { data, head, html: "", redirect, state: {}, status };
261
- }
262
- const assets = (_c = contribution.assets) != null ? _c : descriptor.assets;
263
- const state = _chunkT5QVCXVBcjs.__spreadValues.call(void 0, _chunkT5QVCXVBcjs.__spreadValues.call(void 0, {}, inputs), collectIslandState(container, descriptor));
264
- if (descriptor.view === void 0 || descriptor.viewLayer === void 0) {
265
- return { assets, data, head, html: "", state, status };
266
- }
267
- const rendered = _chunkXOJ2VWX4cjs.resolveViewAdapter.call(void 0, container).renderIsland(descriptor, {
268
- container,
269
- slots: request.slots
270
- });
271
- return { assets, data, head, headHtml: rendered.head, html: rendered.html, state, status };
272
- } finally {
273
- yield container.dispose();
255
+ const assets = (_c = contribution.assets) != null ? _c : descriptor.assets;
256
+ const state = { ...inputs, ...collectIslandState(container, descriptor) };
257
+ if (descriptor.view === void 0 || descriptor.viewLayer === void 0) {
258
+ return { assets, data, head, html: "", state, status };
274
259
  }
275
- });
260
+ const rendered = _chunkMWDNN7Q4cjs.resolveViewAdapter.call(void 0, container).renderIsland(descriptor, {
261
+ container,
262
+ slots: request.slots
263
+ });
264
+ return { assets, data, head, headHtml: rendered.head, html: rendered.html, state, status };
265
+ } finally {
266
+ await container.dispose();
267
+ }
276
268
  }
277
269
 
278
270
  // src/island/routes.ts
@@ -305,7 +297,7 @@ function decodeParams(groups) {
305
297
  var REGEXP_SPECIALS = /[.*+?^${}()|[\]\\]/g;
306
298
  var PARAM_SEGMENT = /\/:([A-Za-z_$][\w$]*)/g;
307
299
  function pathPattern(pattern) {
308
- return `^${pattern.replace(REGEXP_SPECIALS, "\\$&").replace(PARAM_SEGMENT, "/(?<$1>[^/]+)")}$`;
300
+ return "^".concat(pattern.replace(REGEXP_SPECIALS, "\\$&").replace(PARAM_SEGMENT, "/(?<$1>[^/]+)"), "$");
309
301
  }
310
302
 
311
303
 
@@ -1,7 +1,3 @@
1
- import {
2
- __async
3
- } from "./chunk-6FNC3XMI.js";
4
-
5
1
  // src/ops/index.ts
6
2
  import { createServer } from "http";
7
3
  import { ClusterRegistry } from "@prometheus-io/client";
@@ -11,17 +7,30 @@ import { Counter, Gauge as Gauge2, Histogram, Registry } from "@prometheus-io/cl
11
7
 
12
8
  // src/ops/runtime.ts
13
9
  import cluster from "cluster";
10
+ import { performance as performance2 } from "perf_hooks";
14
11
  import { collectDefaultMetrics, Gauge } from "@prometheus-io/client";
15
12
  function collectRuntime(registry, appName) {
16
13
  registry.setDefaultLabels({ app: appName, process_role: cluster.isWorker ? "worker" : "main" });
17
14
  collectDefaultMetrics({ register: registry });
15
+ let previousElu = performance2.eventLoopUtilization();
16
+ new Gauge({
17
+ aggregator: "max",
18
+ collect() {
19
+ const current = performance2.eventLoopUtilization();
20
+ this.set(performance2.eventLoopUtilization(current, previousElu).utilization);
21
+ previousElu = current;
22
+ },
23
+ help: "Event loop utilization since the last scrape; maximum across workers",
24
+ name: "nodejs_eventloop_utilization_ratio",
25
+ registers: [registry]
26
+ });
18
27
  let previousCpu = process.cpuUsage();
19
- let previousTime = performance.now();
28
+ let previousTime = performance2.now();
20
29
  new Gauge({
21
30
  aggregator: "sum",
22
31
  collect() {
23
32
  const currentCpu = process.cpuUsage();
24
- const currentTime = performance.now();
33
+ const currentTime = performance2.now();
25
34
  const elapsed = currentTime - previousTime;
26
35
  this.set(
27
36
  elapsed > 0 ? (currentCpu.user - previousCpu.user + currentCpu.system - previousCpu.system) / (elapsed * 1e3) : 0
@@ -70,8 +79,8 @@ function collectRuntime(registry, appName) {
70
79
  collect() {
71
80
  this.set(process.resourceUsage()[field]);
72
81
  },
73
- help: `Process ${name} since startup`,
74
- name: `process_${name}_total`,
82
+ help: "Process ".concat(name, " since startup"),
83
+ name: "process_".concat(name, "_total"),
75
84
  registers: [registry]
76
85
  });
77
86
  }
@@ -156,64 +165,60 @@ function clusterMetrics(metrics = getProcessMetrics()) {
156
165
  shutdown: () => lifecycle.shutdown()
157
166
  };
158
167
  }
159
- function startOpsServer() {
160
- return __async(this, arguments, function* (options = {}) {
161
- var _a;
162
- const metrics = (_a = options.metrics) != null ? _a : getProcessMetrics();
163
- const server = createServer((req, res) => {
164
- var _a2, _b, _c, _d;
165
- const path = (_a2 = req.url) == null ? void 0 : _a2.split("?")[0];
166
- res.setHeader("cache-control", "no-store");
167
- if (req.method !== "GET" || !["/healthz", "/livez", "/metrics"].includes(path != null ? path : "")) {
168
- res.writeHead(404).end();
169
- return;
168
+ async function startOpsServer(options = {}) {
169
+ var _a;
170
+ const metrics = (_a = options.metrics) != null ? _a : getProcessMetrics();
171
+ const server = createServer((req, res) => {
172
+ var _a2, _b, _c, _d;
173
+ const path = (_a2 = req.url) == null ? void 0 : _a2.split("?")[0];
174
+ res.setHeader("cache-control", "no-store");
175
+ if (req.method !== "GET" || !["/healthz", "/livez", "/metrics"].includes(path != null ? path : "")) {
176
+ res.writeHead(404).end();
177
+ return;
178
+ }
179
+ if (path !== "/metrics") {
180
+ res.writeHead(path === "/livez" && ((_b = options.isLive) == null ? void 0 : _b.call(options)) === false ? 503 : 200, {
181
+ "content-type": "text/plain; charset=utf-8"
182
+ }).end("ok");
183
+ return;
184
+ }
185
+ void ((_d = (_c = options.collect) == null ? void 0 : _c.call(options)) != null ? _d : metrics.registry.metrics()).then((body) => {
186
+ var _a3;
187
+ if (!res.destroyed) {
188
+ res.writeHead(200, { "content-type": (_a3 = options.contentType) != null ? _a3 : metrics.registry.contentType }).end(body);
170
189
  }
171
- if (path !== "/metrics") {
172
- res.writeHead(path === "/livez" && ((_b = options.isLive) == null ? void 0 : _b.call(options)) === false ? 503 : 200, {
173
- "content-type": "text/plain; charset=utf-8"
174
- }).end("ok");
175
- return;
190
+ }).catch(() => {
191
+ if (!res.destroyed) {
192
+ res.writeHead(503).end("metrics unavailable");
176
193
  }
177
- void ((_d = (_c = options.collect) == null ? void 0 : _c.call(options)) != null ? _d : metrics.registry.metrics()).then((body) => {
178
- var _a3;
179
- if (!res.destroyed) {
180
- res.writeHead(200, { "content-type": (_a3 = options.contentType) != null ? _a3 : metrics.registry.contentType }).end(body);
181
- }
182
- }).catch(() => {
183
- if (!res.destroyed) {
184
- res.writeHead(503).end("metrics unavailable");
185
- }
186
- });
187
194
  });
188
- yield new Promise((resolve, reject) => {
189
- var _a2, _b;
190
- server.once("error", reject);
191
- server.listen((_a2 = options.port) != null ? _a2 : 9090, (_b = options.host) != null ? _b : "0.0.0.0", () => {
192
- server.removeListener("error", reject);
193
- resolve();
194
- });
195
+ });
196
+ await new Promise((resolve, reject) => {
197
+ var _a2, _b;
198
+ server.once("error", reject);
199
+ server.listen((_a2 = options.port) != null ? _a2 : 9090, (_b = options.host) != null ? _b : "0.0.0.0", () => {
200
+ server.removeListener("error", reject);
201
+ resolve();
195
202
  });
196
- return server;
197
203
  });
204
+ return server;
198
205
  }
199
- function closeHttpServer(server, timeoutMs = 5e3) {
200
- return __async(this, null, function* () {
201
- if (!server.listening) {
202
- return;
203
- }
204
- yield new Promise((resolve, reject) => {
205
- const timer = setTimeout(() => server.closeAllConnections(), timeoutMs);
206
- timer.unref();
207
- server.close((error) => {
208
- clearTimeout(timer);
209
- if (error) {
210
- reject(error);
211
- } else {
212
- resolve();
213
- }
214
- });
215
- server.closeIdleConnections();
206
+ async function closeHttpServer(server, timeoutMs = 5e3) {
207
+ if (!server.listening) {
208
+ return;
209
+ }
210
+ await new Promise((resolve, reject) => {
211
+ const timer = setTimeout(() => server.closeAllConnections(), timeoutMs);
212
+ timer.unref();
213
+ server.close((error) => {
214
+ clearTimeout(timer);
215
+ if (error) {
216
+ reject(error);
217
+ } else {
218
+ resolve();
219
+ }
216
220
  });
221
+ server.closeIdleConnections();
217
222
  });
218
223
  }
219
224
 
@@ -6,7 +6,7 @@ function installResolver(resolver) {
6
6
  function resolveDefinition(token) {
7
7
  if (activeResolver === null) {
8
8
  throw new Error(
9
- `den/adapter: \u0440\u0435\u0437\u043E\u043B\u0432\u0435\u0440 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D \u0434\u043B\u044F \xAB${token.description}\xBB \u2014 \u043D\u0438 \u043E\u0434\u0438\u043D host-\u0430\u0434\u0430\u043F\u0442\u0435\u0440 \u043D\u0435 \u0432\u044B\u0437\u0432\u0430\u043B installResolver()`
9
+ "den/adapter: \u0440\u0435\u0437\u043E\u043B\u0432\u0435\u0440 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D \u0434\u043B\u044F \xAB".concat(token.description, "\xBB \u2014 ") + "\u043D\u0438 \u043E\u0434\u0438\u043D host-\u0430\u0434\u0430\u043F\u0442\u0435\u0440 \u043D\u0435 \u0432\u044B\u0437\u0432\u0430\u043B installResolver()"
10
10
  );
11
11
  }
12
12
  return activeResolver(token);
@@ -6,7 +6,7 @@ function installResolver(resolver) {
6
6
  function resolveDefinition(token) {
7
7
  if (activeResolver === null) {
8
8
  throw new Error(
9
- `den/adapter: \u0440\u0435\u0437\u043E\u043B\u0432\u0435\u0440 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D \u0434\u043B\u044F \xAB${token.description}\xBB \u2014 \u043D\u0438 \u043E\u0434\u0438\u043D host-\u0430\u0434\u0430\u043F\u0442\u0435\u0440 \u043D\u0435 \u0432\u044B\u0437\u0432\u0430\u043B installResolver()`
9
+ "den/adapter: \u0440\u0435\u0437\u043E\u043B\u0432\u0435\u0440 \u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D \u0434\u043B\u044F \xAB".concat(token.description, "\xBB \u2014 ") + "\u043D\u0438 \u043E\u0434\u0438\u043D host-\u0430\u0434\u0430\u043F\u0442\u0435\u0440 \u043D\u0435 \u0432\u044B\u0437\u0432\u0430\u043B installResolver()"
10
10
  );
11
11
  }
12
12
  return activeResolver(token);