import { NextResponse } from 'next/server'
import { SITE_URL } from '@/lib/core/utils/urls'
export const dynamic = 'force-static'
export const revalidate = 3600
interface Release {
id: number
tag_name: string
name: string
body: string
html_url: string
published_at: string
prerelease: boolean
}
function escapeXml(str: string) {
return str
.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''')
}
export async function GET() {
try {
const res = await fetch('https://api.github.com/repos/simstudioai/sim/releases', {
headers: { Accept: 'application/vnd.github+json' },
next: { revalidate },
})
const releases: Release[] = await res.json()
const items = (releases || [])
.filter((r) => !r.prerelease)
.map(
(r) => `
-
${escapeXml(r.name || r.tag_name)}
${r.html_url}
${r.html_url}
${new Date(r.published_at).toUTCString()}
`
)
.join('')
const xml = `
Sim Changelog
${SITE_URL}/changelog
Latest changes, fixes and updates in Sim.
en-us
${items}
`
return new NextResponse(xml, {
status: 200,
headers: {
'Content-Type': 'application/rss+xml; charset=utf-8',
'Cache-Control': `public, s-maxage=${revalidate}, stale-while-revalidate=${revalidate}`,
},
})
} catch {
return new NextResponse('Service Unavailable', { status: 503 })
}
}