mealie/frontend/api/class-interfaces/utils.ts
Hayden 8eefa05393
Feature/database backups (#1040)
* add annotations to docs

* alchemy data dumper

* initial tests

* sourcery refactor

* db backups/restore

* potential postgres fix

* potential postgres fix

* this is terrible

* potential pg fix

* cleanup

* remove unused import

* fix comparison

* generate frontend types

* update timestamp and add directory filter

* rewrite to new admin-api

* update backup routers

* add file_token response helper

* update imports

* remove test_backup
2022-03-13 15:42:22 -08:00

23 lines
474 B
TypeScript

import { BaseAPI } from "../_base";
const prefix = "/api";
interface DownloadData {
fileToken: string;
}
export class UtilsAPI extends BaseAPI {
async download(url: string) {
const { response } = await this.requests.get<DownloadData>(url);
if (!response) {
return;
}
const token: string = response.data.fileToken;
const tokenURL = prefix + "/utils/download?token=" + token;
window.open(tokenURL, "_blank");
return response;
}
}