mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-21 06:13:48 +00:00
7d375693b9
- Extract shared RSS/Atom fetch logic into feed-fetcher utility (P1-3)
- Split email-processor into validateEmail/storeEmail functions (P1-6)
- Add stateless HMAC-SHA256 CSRF protection to admin forms (P2-8)
- Fix Hono<{ Bindings: Env }> type safety across all routes (P3-13)
- Add entries.test.ts and files.test.ts with full coverage (P1-7)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
904 B
TypeScript
28 lines
904 B
TypeScript
import { Context } from "hono";
|
|
import { Env } from "../types";
|
|
import { ForwardEmailPayload, handleForwardEmail } from "../lib/forwardemail";
|
|
|
|
export async function handle(c: Context<{ Bindings: Env }>): Promise<Response> {
|
|
try {
|
|
const payload: ForwardEmailPayload = await c.req.json();
|
|
|
|
console.log("Received email:", {
|
|
to: payload.recipients?.[0],
|
|
from: payload.from?.text || "Unknown",
|
|
subject: payload.subject,
|
|
contentType: payload.html ? "HTML" : "Text",
|
|
});
|
|
|
|
let ctx: ExecutionContext | undefined;
|
|
try {
|
|
ctx = c.executionCtx;
|
|
} catch {
|
|
// No ExecutionContext in this environment (e.g. tests); WebSub notifications will be skipped
|
|
}
|
|
return handleForwardEmail(payload, c.env, ctx);
|
|
} catch (error) {
|
|
console.error("Error processing email:", error);
|
|
return new Response("Error processing email", { status: 500 });
|
|
}
|
|
}
|