input halo sections, sparkle handling
This commit is contained in:
62
src/routes/api/InputHalo/appcast.xml.ts
Normal file
62
src/routes/api/InputHalo/appcast.xml.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import type { APIEvent } from "@solidjs/start/server";
|
||||
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { env } from "~/env/server";
|
||||
|
||||
/**
|
||||
* Serves the InputHalo appcast.xml file from S3
|
||||
* This endpoint is used by Sparkle updater to check for new versions
|
||||
*
|
||||
* URL: https://freno.me/api/InputHalo/appcast.xml
|
||||
*/
|
||||
export async function GET(event: APIEvent) {
|
||||
const bucket = env.VITE_DOWNLOAD_BUCKET_STRING;
|
||||
const key = "api/InputHalo/appcast.xml";
|
||||
|
||||
const credentials = {
|
||||
accessKeyId: env.MY_AWS_ACCESS_KEY,
|
||||
secretAccessKey: env.MY_AWS_SECRET_KEY
|
||||
};
|
||||
|
||||
try {
|
||||
const client = new S3Client({
|
||||
region: env.AWS_REGION,
|
||||
credentials: credentials
|
||||
});
|
||||
|
||||
const command = new GetObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key
|
||||
});
|
||||
|
||||
const response = await client.send(command);
|
||||
|
||||
if (!response.Body) {
|
||||
return new Response("Appcast not found", {
|
||||
status: 404,
|
||||
headers: {
|
||||
"Content-Type": "text/plain"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Stream the XML content from S3
|
||||
const body = await response.Body.transformToString();
|
||||
|
||||
return new Response(body, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/xml; charset=utf-8",
|
||||
"Cache-Control": "public, max-age=300", // Cache for 5 minutes
|
||||
"Access-Control-Allow-Origin": "*" // Allow CORS for appcast
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch appcast:", error);
|
||||
return new Response("Internal Server Error", {
|
||||
status: 500,
|
||||
headers: {
|
||||
"Content-Type": "text/plain"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { env } from "~/env/server";
|
||||
|
||||
/**
|
||||
* Serves Gaze DMG files and delta updates from S3
|
||||
* Serves macOS app DMG files and delta updates from S3
|
||||
* This endpoint is used by Sparkle updater to download updates
|
||||
*
|
||||
* Handles:
|
||||
* - Full DMG files: /api/downloads/Gaze-0.2.2.dmg
|
||||
* - Delta updates: /api/downloads/Gaze3-2.delta
|
||||
* - Full DMG files: /api/downloads/Gaze-0.2.2.dmg, /api/downloads/InputHalo-0.1.0.dmg
|
||||
* - Delta updates: /api/downloads/Gaze3-2.delta, /api/downloads/InputHalo3-2.delta
|
||||
*
|
||||
* URL: https://freno.me/api/downloads/[filename]
|
||||
*/
|
||||
@@ -24,9 +24,11 @@ export async function GET(event: APIEvent) {
|
||||
});
|
||||
}
|
||||
|
||||
// Validate filename format (only allow Gaze files)
|
||||
// Validate filename format (only allow Gaze or InputHalo files)
|
||||
const validPrefixes = ["Gaze", "InputHalo"];
|
||||
const isValidPrefix = validPrefixes.some((prefix) => filename.startsWith(prefix));
|
||||
if (
|
||||
!filename.startsWith("Gaze") ||
|
||||
!isValidPrefix ||
|
||||
(!filename.endsWith(".dmg") && !filename.endsWith(".delta"))
|
||||
) {
|
||||
return new Response("Invalid file format", {
|
||||
|
||||
Reference in New Issue
Block a user