mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 13:15:18 +02:00
Add version detection endpoint
This commit is contained in:
parent
7086877ba3
commit
172504fa66
2 changed files with 28 additions and 1 deletions
|
@ -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": {
|
||||||
|
|
27
src/routes/api/version/+server.ts
Normal file
27
src/routes/api/version/+server.ts
Normal 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",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue