Skip to content

Commit

Permalink
feat(web): Added api to Website to get the latest and development v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
SaptarshiSarkar12 committed Jan 13, 2024
1 parent e3c492d commit a706a3d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Website/app/api/version/dev/route.js
Original file line number Diff line number Diff line change
@@ -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)
}
13 changes: 13 additions & 0 deletions Website/app/api/version/latest/route.js
Original file line number Diff line number Diff line change
@@ -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)
}

1 comment on commit a706a3d

@vercel
Copy link

@vercel vercel bot commented on a706a3d Jan 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.