mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-23 15:19:41 +02:00
chore: frontend testing setup (#1739)
* add vitest * initialize lib w/ tests * move to dev dep * run tests in CI * update file names * move api folder to lib * move api and api types to same folder * update generator outpath * rm husky * i guess i _did_ need those types * reorg types * extract validators into testable components * (WIP) start composable testing * fix import type * fix linter complaint * simplify icon type def * fix linter errors (maybe?) * rename client file for sorting
This commit is contained in:
parent
9f6bcc83d5
commit
fcc5d99d40
182 changed files with 902 additions and 487 deletions
40
frontend/lib/api/user/backups.ts
Normal file
40
frontend/lib/api/user/backups.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { BaseAPI } from "../base/base-clients";
|
||||
import { 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));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue