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