feat: add BackupCard component and corresponding Backup model to enhance settings functionality and data management

This commit is contained in:
Julien Froidefond
2025-11-30 07:50:47 +01:00
parent f17b83fb95
commit 7cb1d5f433
15 changed files with 1102 additions and 1 deletions

32
app/api/backups/route.ts Normal file
View File

@@ -0,0 +1,32 @@
import { NextRequest, NextResponse } from "next/server";
import { backupService } from "@/services/backup.service";
export async function GET() {
try {
const backups = await backupService.getAllBackups();
return NextResponse.json({ success: true, data: backups });
} catch (error) {
console.error("Error fetching backups:", error);
return NextResponse.json(
{ success: false, error: "Failed to fetch backups" },
{ status: 500 }
);
}
}
export async function POST(request: NextRequest) {
try {
const body = await request.json().catch(() => ({}));
const force = body.force === true; // Only allow force for manual backups
const backup = await backupService.createBackup(force);
return NextResponse.json({ success: true, data: backup });
} catch (error) {
console.error("Error creating backup:", error);
return NextResponse.json(
{ success: false, error: error instanceof Error ? error.message : "Failed to create backup" },
{ status: 500 }
);
}
}