feat: add BackupCard component and corresponding Backup model to enhance settings functionality and data management
This commit is contained in:
30
app/api/backups/settings/route.ts
Normal file
30
app/api/backups/settings/route.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { backupService } from "@/services/backup.service";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const settings = await backupService.getSettings();
|
||||
return NextResponse.json({ success: true, data: settings });
|
||||
} catch (error) {
|
||||
console.error("Error fetching backup settings:", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, error: "Failed to fetch settings" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const settings = await backupService.updateSettings(body);
|
||||
return NextResponse.json({ success: true, data: settings });
|
||||
} catch (error) {
|
||||
console.error("Error updating backup settings:", error);
|
||||
return NextResponse.json(
|
||||
{ success: false, error: "Failed to update settings" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user