mission-control/app/podcast/rss.xml/route.ts

58 lines
2.0 KiB
TypeScript

import { NextResponse } from "next/server";
import { readFileSync, existsSync } from "fs";
import { join } from "path";
const PODCAST_DIR = "/Users/mattbruce/.openclaw/workspace/podcast";
const RSS_FILE = join(PODCAST_DIR, "rss.xml");
export async function GET() {
try {
// Check if RSS file exists
if (!existsSync(RSS_FILE)) {
// Return a default RSS feed if none exists yet
const defaultFeed = `<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<title>OpenClaw Daily Digest</title>
<link>https://mission-control-rho-pink.vercel.app/podcast</link>
<language>en-us</language>
<copyright>© 2026 OpenClaw</copyright>
<itunes:author>OpenClaw</itunes:author>
<description>Daily tech news and insights for developers</description>
<itunes:image href="https://mission-control-rho-pink.vercel.app/podcast-cover.jpg"/>
<itunes:category text="Technology"/>
<itunes:explicit>no</itunes:explicit>
<item>
<title>Welcome to OpenClaw Daily Digest Podcast</title>
<description>Your daily tech news podcast is coming soon. Check back for the first episode!</description>
<pubDate>${new Date().toUTCString()}</pubDate>
<guid isPermaLink="false">welcome</guid>
</item>
</channel>
</rss>`;
return new NextResponse(defaultFeed, {
headers: {
"Content-Type": "application/rss+xml",
"Cache-Control": "public, max-age=3600",
},
});
}
// Read and serve the RSS file
const rssContent = readFileSync(RSS_FILE, "utf-8");
return new NextResponse(rssContent, {
headers: {
"Content-Type": "application/rss+xml",
"Cache-Control": "public, max-age=3600",
},
});
} catch (error) {
console.error("Error serving RSS feed:", error);
return NextResponse.json(
{ error: "Failed to load RSS feed" },
{ status: 500 }
);
}
}