From a706a3d3bdc828a855ba8fd000f6875113d602bf Mon Sep 17 00:00:00 2001 From: Saptarshi Sarkar Date: Sat, 13 Jan 2024 18:44:01 +0530 Subject: [PATCH] feat(web): Added `api` to Website to get the latest and development version --- Website/app/api/version/dev/route.js | 13 +++++++++++++ Website/app/api/version/latest/route.js | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 Website/app/api/version/dev/route.js create mode 100644 Website/app/api/version/latest/route.js diff --git a/Website/app/api/version/dev/route.js b/Website/app/api/version/dev/route.js new file mode 100644 index 000000000..7f0c76082 --- /dev/null +++ b/Website/app/api/version/dev/route.js @@ -0,0 +1,13 @@ +import {NextResponse} from "next/server"; + +export async function getDevelopmentVersion(){ + let devVersionJson = (await fetch("https://raw.githubusercontent.com/SaptarshiSarkar12/Drifty/master/version.json", { + next: {revalidate: 60} + })).text(); + return JSON.parse(await devVersionJson).version; +} + +export async function GET() { + let version = await getDevelopmentVersion(); + return new NextResponse(version) +} \ No newline at end of file diff --git a/Website/app/api/version/latest/route.js b/Website/app/api/version/latest/route.js new file mode 100644 index 000000000..3d710db80 --- /dev/null +++ b/Website/app/api/version/latest/route.js @@ -0,0 +1,13 @@ +import {NextResponse} from "next/server"; + +export async function getLatestVersion(){ + let latestReleases = await fetch("https://api.github.com/repos/SaptarshiSarkar12/Drifty/releases/latest", { + next: { revalidate: 60 } + }).then((res) => res.json()); + return latestReleases.tag_name.replace("v", ""); +} + +export async function GET() { + let version = await getLatestVersion(); + return new NextResponse(version) +} \ No newline at end of file