Versie 0.2.0

This commit is contained in:
Atreides Assets committed 2026-10-29 11:57:29 +01:00
commit e77d8fd373
495 files changed
+81026

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
// Generated, do not edit. sha256:c5d56ec66e3cd8cb38447fbd3bde3d13f334c82cd570f61ee957f449d17935a3
import { mkdtemp, rm, readFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { run } from './db/conn.mjs';
function bestandsnaam() {
const d = new Date();
const p = n => String(n).padStart(2, '0');
return `assetapp-${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}.sqlite`;
}
export async function exportDatabase(res) {
const dir = await mkdtemp(join(tmpdir(), 'assetapp-export-'));
const uit = join(dir, 'export.sqlite');
try {
run(`VACUUM INTO '${uit.replace(/'/g, "''")}'`, []);
const bytes = await readFile(uit);
res.writeHead(200, {
'Content-Type': 'application/vnd.sqlite3',
'Content-Disposition': `attachment; filename="${bestandsnaam()}"`,
'Content-Length': bytes.length,
'Cache-Control': 'no-store',
'X-Content-Type-Options': 'nosniff',
});
res.end(bytes);
} finally {
await rm(dir, { recursive: true, force: true });
}
}