feat: download backup endpoint (db)
This commit is contained in:
parent
3c32096c0f
commit
5488b68226
1 changed files with 28 additions and 1 deletions
|
|
@ -1,7 +1,21 @@
|
|||
import { Body, Controller, Delete, Get, Path, Post, Put, Route, Security } from "tsoa";
|
||||
import express from "express";
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
Path,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
Request,
|
||||
Route,
|
||||
Security,
|
||||
} from "tsoa";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
import { randomUUID } from "crypto";
|
||||
import { getFile } from "../services/minio";
|
||||
|
||||
function getEnvVar(environmentName: string) {
|
||||
const environmentValue = process.env[environmentName];
|
||||
|
|
@ -160,6 +174,19 @@ export class BackupController extends Controller {
|
|||
).then(async (r) => jsonParseOrPlainText(await r.text()));
|
||||
}
|
||||
|
||||
@Get("{name}")
|
||||
async downloadBackup(
|
||||
@Request() req: express.Request,
|
||||
@Path() name: string,
|
||||
@Query() redirect?: boolean,
|
||||
) {
|
||||
const url = await getFile(`${name}.sql.gz`);
|
||||
if (redirect) {
|
||||
return req.res?.redirect(url);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
@Post("restore")
|
||||
async restoreBackup(@Body() body: { name: string }) {
|
||||
const listRunning = await this.runningRestoreStatus();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue