Skip to content

Commit

Permalink
feat(frontend): Show the latest version on /latest.txt. (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
nasa42 authored Feb 2, 2025
1 parent 77a470e commit 220b45d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions frontend/src/pages/latest.txt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { APIRoute } from "astro";
import { readFileSync } from "fs";

export const GET: APIRoute = (_context): Response => {
const file = readFileSync("../Cargo.toml", "utf-8");
const versionMatch = file.match(/^\[workspace\.package\][\s\S]*?version\s*=\s*["'](.+?)["']/m);

const version = versionMatch?.[1];

if (!version) {
throw new Error("Could not find version in Cargo.toml");
}

return new Response(version);
};

0 comments on commit 220b45d

Please sign in to comment.