Files
supabase/apps/studio/pages/api/cli-release-version.ts
Joshen Lim ec7e80bbef Add studio version in header for local self host (#34018)
* Add studio version in header for local self host

* Fix

* Address feedback

* Fix

* Remove Docker Hub context, everything is CLI

* Update to use CLI version as the comparator instead of docker image version

* Fix
2025-04-08 18:06:48 +08:00

32 lines
961 B
TypeScript

import { NextApiRequest, NextApiResponse } from 'next'
type GitHubRepositoryRelease = {
id: number
url: string
name: string
tag_name: string
published_at: string
}
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
// [Joshen] Added under supabase/turbo.json, but not sure why it's still warning
// eslint-disable-next-line turbo/no-undeclared-env-vars
const version = process.env.CURRENT_CLI_VERSION
const fallback = { current: version, latest: null, published_at: null }
try {
const data: GitHubRepositoryRelease[] = await fetch(
'https://api.github.com/repos/supabase/cli/releases?per_page=1'
).then((res) => res.json())
if (data.length === 0) return res.status(200).json(fallback)
return res
.status(200)
.json({ current: version, latest: data[0].tag_name, published_at: data[0].published_at })
} catch {
return res.status(200).json(fallback)
}
}
export default handler