mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-21 14:23:48 +00:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user