mirror of
https://github.com/hay-kot/mealie.git
synced 2025-07-16 10:03:54 -07:00
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend Tests (push) Waiting to run
Docker Nightly Production / Build Package (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
Release Drafter / ✏️ Draft release (push) Waiting to run
Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com> Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { BaseAPI } from "../base/base-clients";
|
|
import type { AllBackups, BackupOptions, CreateBackup } from "~/lib/api/types/admin";
|
|
|
|
const prefix = "/api";
|
|
|
|
const routes = {
|
|
backupsAvailable: `${prefix}/backups/available`,
|
|
backupsExportDatabase: `${prefix}/backups/export/database`,
|
|
backupsUpload: `${prefix}/backups/upload`,
|
|
|
|
backupsFileNameDownload: (fileName: string) => `${prefix}/backups/${fileName}/download`,
|
|
backupsFileNameImport: (fileName: string) => `${prefix}/backups/${fileName}/import`,
|
|
backupsFileNameDelete: (fileName: string) => `${prefix}/backups/${fileName}/delete`,
|
|
};
|
|
|
|
export class BackupAPI extends BaseAPI {
|
|
/** Returns a list of available .zip files for import into Mealie.
|
|
*/
|
|
async getAll() {
|
|
return await this.requests.get<AllBackups>(routes.backupsAvailable);
|
|
}
|
|
|
|
/** Generates a backup of the recipe database in json format.
|
|
*/
|
|
async createOne(payload: CreateBackup) {
|
|
return await this.requests.post(routes.backupsExportDatabase, payload);
|
|
}
|
|
|
|
/** Import a database backup file generated from Mealie.
|
|
*/
|
|
async restoreDatabase(fileName: string, payload: BackupOptions) {
|
|
return await this.requests.post(routes.backupsFileNameImport(fileName), { name: fileName, ...payload });
|
|
}
|
|
|
|
/** Removes a database backup from the file system
|
|
*/
|
|
async deleteOne(fileName: string) {
|
|
return await this.requests.delete(routes.backupsFileNameDelete(fileName));
|
|
}
|
|
}
|