mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 21:00:41 +00:00
1cef45e373
- Introduced `shared.ts` with utility functions for API interactions, including JSON parsing, error handling, and content disposition parsing. - Added `vault.ts` to manage vault-related operations such as folder and cipher management, including creation, deletion, and bulk operations. - Implemented encryption and decryption methods for secure data handling within the vault. - Created `backup-settings-repair.ts` to automatically repair backup settings for admin profiles if needed.
65 lines
2.1 KiB
TypeScript
65 lines
2.1 KiB
TypeScript
import type { Env, User } from './types';
|
|
import {
|
|
handleAdminExportBackup,
|
|
handleDownloadAdminRemoteBackup,
|
|
handleDeleteAdminRemoteBackup,
|
|
handleGetAdminBackupSettings,
|
|
handleGetAdminBackupSettingsRepairState,
|
|
handleAdminImportBackup,
|
|
handleListAdminRemoteBackups,
|
|
handleRepairAdminBackupSettings,
|
|
handleRestoreAdminRemoteBackup,
|
|
handleRunAdminConfiguredBackup,
|
|
handleUpdateAdminBackupSettings,
|
|
} from './handlers/backup';
|
|
|
|
export async function handleAdminBackupRoute(
|
|
request: Request,
|
|
env: Env,
|
|
actorUser: User,
|
|
path: string,
|
|
method: string
|
|
): Promise<Response | null> {
|
|
if (path === '/api/admin/backup/export' && method === 'POST') {
|
|
return handleAdminExportBackup(request, env, actorUser);
|
|
}
|
|
|
|
if (path === '/api/admin/backup/settings') {
|
|
if (method === 'GET') return handleGetAdminBackupSettings(request, env, actorUser);
|
|
if (method === 'PUT') return handleUpdateAdminBackupSettings(request, env, actorUser);
|
|
return null;
|
|
}
|
|
|
|
if (path === '/api/admin/backup/settings/repair') {
|
|
if (method === 'GET') return handleGetAdminBackupSettingsRepairState(request, env, actorUser);
|
|
if (method === 'POST') return handleRepairAdminBackupSettings(request, env, actorUser);
|
|
return null;
|
|
}
|
|
|
|
if (path === '/api/admin/backup/run' && method === 'POST') {
|
|
return handleRunAdminConfiguredBackup(request, env, actorUser);
|
|
}
|
|
|
|
if (path === '/api/admin/backup/remote' && method === 'GET') {
|
|
return handleListAdminRemoteBackups(request, env, actorUser);
|
|
}
|
|
|
|
if (path === '/api/admin/backup/remote/download' && method === 'GET') {
|
|
return handleDownloadAdminRemoteBackup(request, env, actorUser);
|
|
}
|
|
|
|
if (path === '/api/admin/backup/remote/file' && method === 'DELETE') {
|
|
return handleDeleteAdminRemoteBackup(request, env, actorUser);
|
|
}
|
|
|
|
if (path === '/api/admin/backup/remote/restore' && method === 'POST') {
|
|
return handleRestoreAdminRemoteBackup(request, env, actorUser);
|
|
}
|
|
|
|
if (path === '/api/admin/backup/import' && method === 'POST') {
|
|
return handleAdminImportBackup(request, env, actorUser);
|
|
}
|
|
|
|
return null;
|
|
}
|