Remove excludeRows and appName from the querystrings

This commit is contained in:
Adria Navarro 2023-06-14 11:06:46 +01:00
parent bfd444dbaa
commit a68dc7c965
2 changed files with 16 additions and 9 deletions

View File

@ -16,9 +16,8 @@
const exportApp = async () => {
const id = published ? app.prodId : app.devId
const appName = encodeURIComponent(app.name)
const url = `/api/backups/export?appId=${id}&appname=${appName}&excludeRows=${excludeRows}`
await downloadFile(url)
const url = `/api/backups/export?appId=${id}`
await downloadFile(url, { excludeRows })
}
export async function downloadFile(url, body) {

View File

@ -1,14 +1,22 @@
import sdk from "../../sdk"
import { events, context } from "@budibase/backend-core"
import { events, context, db } from "@budibase/backend-core"
import { DocumentType } from "../../db/utils"
import { isQsTrue } from "../../utilities"
import { Ctx } from "@budibase/types"
interface ExportAppDumpRequest {
excludeRows: boolean
}
export async function exportAppDump(ctx: Ctx<ExportAppDumpRequest>) {
const { appId } = ctx.query as any
const { excludeRows } = ctx.request.body
const [app] = await db.getAppsByIDs([appId])
const appName = app.name
export async function exportAppDump(ctx: any) {
let { appId, excludeRows } = ctx.query
// remove the 120 second limit for the request
ctx.req.setTimeout(0)
const appName = decodeURI(ctx.query.appname)
excludeRows = isQsTrue(excludeRows)
const backupIdentifier = `${appName}-export-${new Date().getTime()}.tar.gz`
ctx.attachment(backupIdentifier)
ctx.body = await sdk.backups.streamExportApp(appId, excludeRows)