mirror of
https://github.com/zadam/trilium.git
synced 2026-05-06 19:06:35 +02:00
chore(core): integrate backup routes
This commit is contained in:
@@ -172,9 +172,7 @@ function register(app: express.Application) {
|
||||
asyncRoute(PST, "/api/database/rebuild/", [auth.checkApiAuthOrElectron], databaseRoute.rebuildIntegrationTestDatabase, apiResultHandler);
|
||||
}
|
||||
|
||||
// backup requires execution outside of transaction
|
||||
asyncRoute(PST, "/api/database/backup-database", [auth.checkApiAuthOrElectron, csrfMiddleware], databaseRoute.backupDatabase, apiResultHandler);
|
||||
apiRoute(GET, "/api/database/backups", databaseRoute.getExistingBackups);
|
||||
// backup/download is server-specific (uses Express res.download), backup-database and backups are in core
|
||||
route(GET, "/api/database/backup/download", [auth.checkApiAuthOrElectron], databaseRoute.downloadBackup);
|
||||
// VACUUM requires execution outside of transaction
|
||||
asyncRoute(PST, "/api/database/vacuum-database", [auth.checkApiAuthOrElectron, csrfMiddleware], databaseRoute.vacuumDatabase, apiResultHandler);
|
||||
|
||||
17
packages/trilium-core/src/routes/api/backup.ts
Normal file
17
packages/trilium-core/src/routes/api/backup.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { BackupDatabaseNowResponse, DatabaseBackup } from "@triliumnext/commons";
|
||||
import { getBackup } from "../../services/backup.js";
|
||||
|
||||
function getExistingBackups(): DatabaseBackup[] {
|
||||
return getBackup().getExistingBackups();
|
||||
}
|
||||
|
||||
async function backupDatabase(): Promise<BackupDatabaseNowResponse> {
|
||||
return {
|
||||
backupFile: await getBackup().backupNow("now")
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
getExistingBackups,
|
||||
backupDatabase
|
||||
};
|
||||
@@ -29,6 +29,7 @@ import importRoute from "./api/import";
|
||||
import exportRoute from "./api/export";
|
||||
import scriptRoute from "./api/script";
|
||||
import backendLogRoute from "./api/backend_log";
|
||||
import backupRoute from "./api/backup";
|
||||
|
||||
// TODO: Deduplicate with routes.ts
|
||||
const GET = "get",
|
||||
@@ -201,6 +202,10 @@ export function buildSharedApiRoutes({ route, asyncRoute, apiRoute, asyncApiRout
|
||||
apiRoute(GET, "/api/app-info", appInfoRoute.getAppInfo);
|
||||
asyncApiRoute(GET, "/api/backend-log", backendLogRoute.getBackendLog);
|
||||
|
||||
// Backup routes
|
||||
apiRoute(GET, "/api/database/backups", backupRoute.getExistingBackups);
|
||||
asyncApiRoute(PST, "/api/database/backup-database", backupRoute.backupDatabase);
|
||||
|
||||
apiRoute(GET, "/api/other/icon-usage", otherRoute.getIconUsage);
|
||||
apiRoute(PST, "/api/other/render-markdown", otherRoute.renderMarkdown);
|
||||
apiRoute(PST, "/api/other/to-markdown", otherRoute.toMarkdown);
|
||||
|
||||
Reference in New Issue
Block a user