-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: website binary downloads path structure
- Loading branch information
1 parent
5a5fb05
commit e02f29f
Showing
4 changed files
with
46 additions
and
96 deletions.
There are no files selected for viewing
32 changes: 0 additions & 32 deletions
32
apps/website/pages/api/downloads/hostd/latest/[platform].ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { GitHubRelease } from '@siafoundation/data-sources' | ||
import { | ||
getHostdLatestRelease, | ||
getRenterdLatestRelease, | ||
getWalletdLatestRelease, | ||
} from '../../../../content/releases' | ||
import fetch from 'node-fetch' | ||
|
||
export const config = { | ||
api: { | ||
responseLimit: false, | ||
}, | ||
} | ||
|
||
export default async function handler(req, res) { | ||
const { name } = req.query | ||
try { | ||
let daemon = '' | ||
let latest: GitHubRelease = null | ||
if (name.includes('hostd')) { | ||
daemon = 'hostd' | ||
latest = await getHostdLatestRelease() | ||
} | ||
if (name.includes('renterd')) { | ||
daemon = 'renterd' | ||
latest = await getRenterdLatestRelease() | ||
} | ||
if (name.includes('walletd')) { | ||
daemon = 'walletd' | ||
latest = await getWalletdLatestRelease() | ||
} | ||
const githubUrl = `https://github.com/SiaFoundation/${daemon}/releases/download/${latest.tag_name}/${name}` | ||
|
||
const response = await fetch(githubUrl) | ||
|
||
if (!response.ok) throw new Error(`Failed to fetch ${githubUrl}`) | ||
|
||
res.setHeader('Content-Type', 'application/zip') | ||
res.setHeader('Content-Disposition', `attachment; filename=${name}`) | ||
|
||
response.body.pipe(res) | ||
} catch (error) { | ||
console.error('Error fetching the file:', error) | ||
res.status(500).send('Internal Server Error') | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
apps/website/pages/api/downloads/renterd/latest/[platform].ts
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
apps/website/pages/api/downloads/walletd/latest/[platform].ts
This file was deleted.
Oops, something went wrong.