mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
feat(api): expose app version in /api/v1/stats
Add version to StatsResponse and getStats so the canonical public monitoring endpoint reports the running build alongside the footer and /health. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Counters, Env, StatsResponse } from "../types";
|
||||
import { APP_VERSION } from "../config/version";
|
||||
import { logger } from "../infrastructure/logger";
|
||||
import { FeedRepository } from "../infrastructure/feed-repository";
|
||||
import { CountersRepository } from "../infrastructure/counters-repository";
|
||||
@@ -77,6 +78,7 @@ export async function getStats(env: Env): Promise<StatsResponse> {
|
||||
active_feeds: feeds.length,
|
||||
websub_subscriptions_active: websubCount,
|
||||
attachments_enabled: !!getAttachmentBucket(env),
|
||||
version: APP_VERSION,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -295,10 +295,12 @@ describe("REST API (/api/v1)", () => {
|
||||
feeds_created: number;
|
||||
active_feeds: number;
|
||||
attachments_enabled: boolean;
|
||||
version: string;
|
||||
};
|
||||
expect(stats.feeds_created).toBeGreaterThanOrEqual(1);
|
||||
expect(stats.active_feeds).toBeGreaterThanOrEqual(1);
|
||||
expect(typeof stats.attachments_enabled).toBe("boolean");
|
||||
expect(stats.version).toMatch(/^\d+\.\d+\.\d+/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -154,6 +154,9 @@ export const StatsSchema = z
|
||||
active_feeds: z.number(),
|
||||
websub_subscriptions_active: z.number(),
|
||||
attachments_enabled: z.boolean(),
|
||||
version: z.string().openapi({
|
||||
description: "Running app version (package.json), inlined at build time.",
|
||||
}),
|
||||
last_email_at: z.string().optional(),
|
||||
last_feed_created_at: z.string().optional(),
|
||||
first_seen: z.string().optional(),
|
||||
|
||||
@@ -125,6 +125,7 @@ export interface StatsResponse extends Counters {
|
||||
active_feeds: number;
|
||||
websub_subscriptions_active: number;
|
||||
attachments_enabled: boolean;
|
||||
version: string; // Running app version (package.json), inlined at build time
|
||||
}
|
||||
|
||||
// WebSub (PubSubHubbub) subscription configuration
|
||||
|
||||
Reference in New Issue
Block a user