refactor(domain): split Icon/WebSub/Counters out of FeedRepository

FeedRepository no longer owns favicons, WebSub subscriber lists or the
monitoring counters singleton. Each concern gets its own repository
(IconRepository, WebSubSubscriptionRepository, CountersRepository),
sharing the key schema via feed-keys. KV key strings are unchanged;
counters increment policy stays in utils/stats.ts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Julien Herr
2026-05-24 00:27:33 +02:00
parent b347f2f625
commit a31ff42f59
13 changed files with 204 additions and 119 deletions
+23
View File
@@ -0,0 +1,23 @@
import { Counters, Env } from "../types";
import { STATS_KEY } from "./feed-keys";
/**
* KV access for the monitoring counters singleton (`stats:counters`). The
* increment policy lives in the application layer (utils/stats.ts); this
* repository owns only the raw read/write of the blob.
*/
export class CountersRepository {
constructor(private readonly kv: KVNamespace) {}
static from(env: Env): CountersRepository {
return new CountersRepository(env.EMAIL_STORAGE);
}
async getRaw(): Promise<Counters | null> {
return (await this.kv.get(STATS_KEY, { type: "json" })) as Counters | null;
}
async put(counters: Counters): Promise<void> {
await this.kv.put(STATS_KEY, JSON.stringify(counters));
}
}