mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
7bf0f71f86
Replace the history-driven lib/ + utils/ split with DDD layers: - domain/: aggregate, repositories, value objects, pure parsers/format - application/: feed-service, email-processor, feed-fetcher, stats - infrastructure/: logging, auth, KV/R2 adapters, HTTP, framework glue Pure file relocation; imports updated mechanically. Behaviour unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
31 lines
808 B
TypeScript
31 lines
808 B
TypeScript
import { Env } from "../types";
|
|
|
|
export function baseUrl(env: Env): string {
|
|
return `https://${env.DOMAIN}`;
|
|
}
|
|
|
|
export function feedRssUrl(feedId: string, env: Env): string {
|
|
return `${baseUrl(env)}/rss/${feedId}`;
|
|
}
|
|
|
|
export function feedAtomUrl(feedId: string, env: Env): string {
|
|
return `${baseUrl(env)}/atom/${feedId}`;
|
|
}
|
|
|
|
export function feedUrl(
|
|
format: "rss" | "atom",
|
|
feedId: string,
|
|
env: Env,
|
|
): string {
|
|
return format === "rss" ? feedRssUrl(feedId, env) : feedAtomUrl(feedId, env);
|
|
}
|
|
|
|
export function feedEmailAddress(feedId: string, env: Env): string {
|
|
return `${feedId}@${env.EMAIL_DOMAIN ?? env.DOMAIN}`;
|
|
}
|
|
|
|
export function feedTopicPattern(env: Env): RegExp {
|
|
const escaped = env.DOMAIN.replaceAll(".", "\\.");
|
|
return new RegExp(`^https://${escaped}/(rss|atom)/([^/]+)$`);
|
|
}
|