Skip to content

Commit

Permalink
feat: latest download api
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Jan 30, 2024
1 parent 9cc5368 commit 1f06a70
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pages/api/download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import getLatestRelease from "../../util/cache"

export default async function handler(req, res) {
const data = await getLatestRelease()
// get version name template from query, e.g. ?tpl=Gopeed-$version-ios.ipa
const { tpl } = req.query
// replace $version with version name
const filename = tpl.replace('$version', data.tag_name)
// redirect to download url
res.redirect(`https://github.com/GopeedLab/gopeed/releases/latest/download/${filename}`)
}

0 comments on commit 1f06a70

Please sign in to comment.