1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-05 05:05:17 +02:00

Add version detection endpoint

This commit is contained in:
Sean Morley 2024-04-20 16:59:03 +00:00
parent 7086877ba3
commit 172504fa66
2 changed files with 28 additions and 1 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "adventurelog", "name": "adventurelog",
"version": "0.1.0", "version": "0.1.6",
"description": "Embark, Explore, Remember. 🌍", "description": "Embark, Explore, Remember. 🌍",
"private": true, "private": true,
"scripts": { "scripts": {

View file

@ -0,0 +1,27 @@
import type { RequestEvent } from "@sveltejs/kit";
import { readFileSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const packageJsonPath = join(__dirname, "..", "..", "..", "..", "package.json");
const json = readFileSync(packageJsonPath, "utf8");
const pkg = JSON.parse(json);
const version = pkg.version;
/**
* Handles the GET request for the version API endpoint.
* @param event - The request event object.
* @returns A Promise that resolves to a Response object.
*/
export async function GET(event: RequestEvent): Promise<Response> {
return new Response(JSON.stringify({ version: version }), {
status: 200,
headers: {
"Content-Type": "application/json",
},
});
}