import { NextRequest, NextResponse } from 'next/server'; import fs from 'fs'; import path from 'path'; import serverConfig from '@lifetracker/shared/config'; const DB_PATH = path.join(serverConfig.dataDir, 'lifetracker.db'); export async function GET(req: NextRequest) { try { // Read the production database file const dbFile = fs.readFileSync(DB_PATH); return new NextResponse(dbFile, { headers: { 'Content-Type': 'application/octet-stream', 'Content-Disposition': 'attachment; filename="lifetracker.db"' } }); } catch (error) { console.error('Error downloading the database:', error); return NextResponse.json({ message: 'Error processing download.' }, { status: 500 }); } }