Skip to content

Commit

Permalink
Merge pull request #41 from parkerreno/dev/listFirmwareFix
Browse files Browse the repository at this point in the history
List firmware fix for firmware >2.5.4
  • Loading branch information
thebentern authored Nov 10, 2024
2 parents fa248b9 + d8b1972 commit aba1f37
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/routes/firmware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface FirmwareReleases {
}

export const FirmwareRoutes = () => {
return app.get("/github/firmware/list", async (_, res) => {
return app.get("/github/firmware/list", async (req, res) => {
const releaseCache = await redis.get("gh-releases");

if (releaseCache) {
Expand Down Expand Up @@ -54,6 +54,11 @@ export const FirmwareRoutes = () => {
})
);

// Firmware is now separated & suffixed by platform (e.g. firmware-esp32) as of 2.5.5
// If we don't find a result (or it's not provided), fallback to the old firmware- prefix
// to avoid a breaking change to the API
const filteredString: string = "firmware-" + (req.query.platform ?? "");

const firmwareReleases: FirmwareReleases = {
releases: {
stable: releases
Expand All @@ -63,9 +68,11 @@ export const FirmwareRoutes = () => {
id: release.tag_name,
title: release.name,
page_url: release.html_url,
zip_url: release.assets.find((asset) =>
zip_url: (release.assets.find((asset) =>
asset.name.startsWith(filteredString)
) ?? release.assets.find((asset) =>
asset.name.startsWith("firmware-")
)?.browser_download_url,
))?.browser_download_url,
release_notes: release.body,
};
}),
Expand All @@ -76,9 +83,11 @@ export const FirmwareRoutes = () => {
id: release.tag_name,
title: release.name,
page_url: release.html_url,
zip_url: release.assets.find((asset) =>
zip_url: (release.assets.find((asset) =>
asset.name.startsWith(filteredString)
) ?? release.assets.find((asset) =>
asset.name.startsWith("firmware-")
)?.browser_download_url,
))?.browser_download_url,
release_notes: release.body,
};
}),
Expand Down

0 comments on commit aba1f37

Please sign in to comment.