Files
supabase/apps/studio/pages/api/cli-release-version.ts
Joshen Lim 7f5865872a Enforce noUnusedLocals and noUnusedParameters in tsconfig.json + fix all related issues (#45264)
## Context

Enforce `noUnusedLocals` and `noUnusedParameters` in tsconfig.json + fix
all related issues
2026-04-27 17:42:34 +08:00

34 lines
979 B
TypeScript

import { NextApiRequest, NextApiResponse } from 'next'
type GitHubRepositoryRelease = {
id: number
url: string
name: string
tag_name: string
published_at: string
}
const current = process.env.CURRENT_CLI_VERSION ? `v${process.env.CURRENT_CLI_VERSION}` : undefined
const handler = async (_req: NextApiRequest, res: NextApiResponse) => {
try {
const { tag_name: latest, published_at }: GitHubRepositoryRelease = await fetch(
'https://api.github.com/repos/supabase/cli/releases/latest'
).then((res) => res.json())
const data: GitHubRepositoryRelease[] = await fetch(
'https://api.github.com/repos/supabase/cli/releases?per_page=1'
)
.then((res) => res.json())
// Ignore errors fetching beta release version
.catch(() => [])
const beta = data[0]?.tag_name
return res.status(200).json({ current, latest, beta, published_at })
} catch {
return res.status(200).json({ current })
}
}
export default handler