- docker-compose stack: podpuddle + MediaMTX (RTMP/WHIP/HLS) + blossom-server - NIP-98 nostr-only login with session cookies, replay guard, clock-skew window - podcasts/episodes CRUD; episodes register browser-uploaded blossom blobs - RSS 2.0 + itunes + podcast namespace feeds with lnaddress value blocks (podcast:guid UUIDv5 verified against the spec vector) - streams API with hashed stream keys; MediaMTX http-auth webhook (query/password/bearer forms); API poller flips live/ended status - NIP-53 kind 30311 live events published with the server's nostr identity - recordings: ffmpeg remux + server-key blossom upload → podcast episode - 35 vitest tests green Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import { createHash } from 'node:crypto';
|
|
import type { FastifyInstance } from 'fastify';
|
|
import { buildFeedXml } from '../services/rss.js';
|
|
import type { Episode, Podcast } from '../types.js';
|
|
|
|
export default async function feedRoutes(app: FastifyInstance) {
|
|
const { db, settings } = app.ctx;
|
|
|
|
const getPodcast = db.prepare('SELECT * FROM podcasts WHERE id = ?');
|
|
const listEpisodes = db.prepare('SELECT * FROM episodes WHERE podcast_id = ? ORDER BY pub_date DESC');
|
|
|
|
app.get('/feeds/:id/feed.xml', async (req, reply) => {
|
|
const { id } = req.params as { id: string };
|
|
const podcast = getPodcast.get(id) as Podcast | undefined;
|
|
if (!podcast) return reply.code(404).send({ error: 'feed not found' });
|
|
|
|
const episodes = listEpisodes.all(id) as Episode[];
|
|
const xml = buildFeedXml(podcast, episodes, { publicUrl: settings.all().public_url });
|
|
const etag = `"${createHash('sha256').update(xml).digest('hex').slice(0, 16)}"`;
|
|
|
|
if (req.headers['if-none-match'] === etag) return reply.code(304).send();
|
|
return reply
|
|
.header('content-type', 'application/rss+xml; charset=utf-8')
|
|
.header('etag', etag)
|
|
.header('cache-control', 'public, max-age=60')
|
|
.send(xml);
|
|
});
|
|
}
|