yedra 0.13.13 → 0.13.15

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.
@@ -8,6 +8,11 @@ declare class Context {
8
8
  constructor(server: Server);
9
9
  stop(): Promise<void>;
10
10
  }
11
+ type MetricsConfig = {
12
+ port: number;
13
+ path: string;
14
+ get?: () => Promise<string>;
15
+ };
11
16
  export declare class Yedra {
12
17
  private restRoutes;
13
18
  private wsRoutes;
@@ -15,10 +20,7 @@ export declare class Yedra {
15
20
  private requestData;
16
21
  private readonly metricsEndpoint;
17
22
  constructor(options?: {
18
- metrics: {
19
- port: number;
20
- path: string;
21
- };
23
+ metrics: MetricsConfig;
22
24
  });
23
25
  use(path: string, endpoint: RestEndpoint | WsEndpoint | Yedra): Yedra;
24
26
  static(dir: string, fallback?: string): Promise<void>;
@@ -193,10 +193,14 @@ export class Yedra {
193
193
  const metricsEndpoint = this.metricsEndpoint;
194
194
  if (metricsEndpoint !== undefined) {
195
195
  const metricsServer = createHttpServer();
196
- metricsServer.on('request', (req, res) => {
196
+ metricsServer.on('request', async (req, res) => {
197
197
  if (req.method === 'GET' && req.url === metricsEndpoint.path) {
198
198
  res.writeHead(200);
199
- res.end(this.generateMetrics());
199
+ res.write(this.generateMetrics());
200
+ if (metricsEndpoint.get !== undefined) {
201
+ res.write(await metricsEndpoint.get());
202
+ }
203
+ res.end();
200
204
  }
201
205
  else {
202
206
  res.writeHead(404);
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "yedra",
3
- "version": "0.13.13",
3
+ "version": "0.13.15",
4
4
  "repository": "github:0codekit/yedra",
5
5
  "main": "dist/index.js",
6
6
  "devDependencies": {
7
7
  "@biomejs/biome": "^1.9.4",
8
- "@types/bun": "^1.2.8",
9
- "@types/node": "^22.14.0",
8
+ "@types/bun": "^1.2.10",
9
+ "@types/node": "^22.14.1",
10
10
  "@types/uuid": "^10.0.0",
11
11
  "@types/ws": "^8.18.1",
12
- "typescript": "^5.8.2"
12
+ "typescript": "^5.8.3"
13
13
  },
14
14
  "bugs": "https://github.com/0codekit/yedra/issues",
15
15
  "contributors": ["Justus Zorn <jzorn@wemakefuture.com>"],
@@ -23,7 +23,7 @@
23
23
  "types": "dist/index.d.ts",
24
24
  "type": "module",
25
25
  "dependencies": {
26
- "mime": "^4.0.6",
26
+ "mime": "^4.0.7",
27
27
  "uuid": "^11.1.0",
28
28
  "ws": "^8.18.1"
29
29
  }