{"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../src/astro/routes/api/settings/backups/archives/index.ts"],"sourcesContent":["/**\n * Backup archives — create\n *\n * POST /_emdash/api/settings/backups/archives — generate a backup and store\n * it in the storage backend under `backups/`, pruning archives beyond the\n * configured retention.\n */\n\nimport type { APIRoute } from \"astro\";\n\nimport { requirePerm } from \"#api/authorize.js\";\nimport { apiError, unwrapResult } from \"#api/error.js\";\nimport { getBackupSettings, runBackupToStorage } from \"#api/handlers/backup.js\";\n\nexport const prerender = false;\n\nexport const POST: APIRoute = async ({ locals }) => {\n\tconst { emdash, user } = locals;\n\n\tif (!emdash?.db) {\n\t\treturn apiError(\"NOT_CONFIGURED\", \"EmDash is not initialized\", 500);\n\t}\n\n\tconst denied = requirePerm(user, \"backups:manage\");\n\tif (denied) return denied;\n\n\tif (!emdash.storage) {\n\t\treturn apiError(\"STORAGE_NOT_CONFIGURED\", \"No storage backend is configured\", 503);\n\t}\n\n\tconst settings = await getBackupSettings(emdash.db);\n\treturn unwrapResult(await runBackupToStorage(emdash.db, emdash.storage, settings.retention), 201);\n};\n"],"mappings":";;;;;;;;;AAcA,MAAa,YAAY;AAEzB,MAAa,OAAiB,OAAO,EAAE,aAAa;CACnD,MAAM,EAAE,QAAQ,SAAS;AAEzB,KAAI,CAAC,QAAQ,GACZ,QAAO,SAAS,kBAAkB,6BAA6B,IAAI;CAGpE,MAAM,SAAS,YAAY,MAAM,iBAAiB;AAClD,KAAI,OAAQ,QAAO;AAEnB,KAAI,CAAC,OAAO,QACX,QAAO,SAAS,0BAA0B,oCAAoC,IAAI;CAGnF,MAAM,WAAW,MAAM,kBAAkB,OAAO,GAAG;AACnD,QAAO,aAAa,MAAM,mBAAmB,OAAO,IAAI,OAAO,SAAS,SAAS,UAAU,EAAE,IAAI"}