Files
forgery/src/api/backup.ts
T
google-labs-jules[bot] a452d79802 Refactor backup/restore to Service Layer and add comprehensive tests
- Create `BackupService` in `src/service/backup.ts` to encapsulate tar stream creation and restore logic (db connection, fs operations).
- Refactor `src/api/backup.ts` and `src/api/restore.ts` to use `BackupService`.
- Add unit tests for `BackupService` in `src/service/backup.test.ts`.
- Add API tests for backup and restore endpoints in `src/api/backup.test.ts` and `src/api/restore.test.ts`.
- Maintain existing functionality: uncompressed tar streaming, safe restore with rollback.
2026-02-15 05:30:33 +00:00

19 lines
452 B
TypeScript

import { Hono } from 'hono'
import { backupService } from '../service/backup'
const app = new Hono()
app.get('/', async () => {
const stream = backupService.createBackupStream()
// @ts-ignore: Bun supports Readable in Response, but TS doesn't know fully
return new Response(stream, {
headers: {
'Content-Type': 'application/x-tar',
'Content-Disposition': 'attachment; filename="backup.tar"',
},
})
})
export default app