import type { RequestHandler } from './$types'; import { createBackupStream, backupFilename } from '$lib/server/backup/export'; import { DATABASE_PATH, IMAGE_DIR } from '$lib/server/paths'; import { Readable } from 'node:stream'; export const GET: RequestHandler = async () => { const archive = createBackupStream({ dbPath: DATABASE_PATH, imagesDir: IMAGE_DIR }); const filename = backupFilename(); return new Response(Readable.toWeb(archive) as ReadableStream, { status: 200, headers: { 'content-type': 'application/zip', 'content-disposition': `attachment; filename="${filename}"` } }); };