feat(m14): backup & admin (zip via fflate, admin guard, tests, e2e)

- BackupService (admin-only: createBackup zips DB+uploads via fflate to
  backups/backup-<ts>.zip, listBackups newest-first, getBackupPath with
  path-traversal guard)
- Admin backup APIs: GET/POST /api/admin/backups, GET /api/admin/backups/:filename
- Admin backups screen (admin-only) + BackupCreateButton
- Playwright globalSetup seeds a system_admin user for admin E2E
- add fflate dependency
- Unit tests (BackupService: zip content, list, admin guard, traversal) +
  e2e backup (create/list/download + non-admin 403)
This commit is contained in:
Ken Yasue
2026-06-25 02:35:35 +02:00
parent 384e61386a
commit 0026edd22b
9 changed files with 346 additions and 1 deletions

View File

@ -25,6 +25,7 @@ import { MeetingService } from '@/services/MeetingService';
import { MeetingRepository } from '@/repositories/MeetingRepository';
import { SearchService } from '@/services/SearchService';
import { DashboardService } from '@/services/DashboardService';
import { BackupService } from '@/services/BackupService';
/**
* Route Handler用に各Repository/Serviceを構築するファクトリ。
@ -168,6 +169,13 @@ export function createDashboardService(): DashboardService {
);
}
export function createBackupService(): BackupService {
const dbPath = process.env.SQLITE_PATH ?? './data/app.db';
const uploadsDir = process.env.UPLOADS_PATH ?? './data/uploads';
const backupsDir = './backups';
return new BackupService(dbPath, uploadsDir, backupsDir);
}
export function createUserRepository(): UserRepository {
return new UserRepository(getDb());
}