updated expressjs project

This commit is contained in:
Ludwig Lehnert
2026-01-12 17:14:01 +01:00
parent f4c09a259c
commit ffdc4cf43e
2 changed files with 24 additions and 21 deletions

0
deploy.sh Normal file → Executable file
View File

View File

@@ -95,7 +95,8 @@ function all(sql, params = []) {
function parseLogins(contents) { function parseLogins(contents) {
const entries = new Map(); const entries = new Map();
const lines = contents.split(/\r?\n/); const lines = contents.split(/\r?\n/);
for (const line of lines) { for (const rawLine of lines) {
const line = rawLine.trim();
if (!line || line.startsWith('#')) { if (!line || line.startsWith('#')) {
continue; continue;
} }
@@ -204,24 +205,26 @@ function renderPage(title, body) {
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>${title}</title> <title>${title}</title>
<style> <style>
body { font-family: Arial, sans-serif; margin: 0; background: #f4f6f8; color: #1f2933; } :root { --ink:#0f172a; --muted:#6b7280; --line:#e5e7eb; --bg:#f7f7f4; --card:#ffffff; --accent:#111827; }
main { max-width: 920px; margin: 0 auto; padding: 24px 16px 48px; } * { box-sizing: border-box; }
body { margin: 0; font-family: "IBM Plex Sans", "Noto Sans", sans-serif; color: var(--ink); background: var(--bg); }
main { max-width: 920px; margin: 0 auto; padding: 22px 16px 48px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; } header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 1.6rem; } h1 { margin: 0; font-size: 1.55rem; }
h2 { margin: 0 0 12px; font-size: 1.15rem; } h2 { margin: 0 0 12px; font-size: 1.08rem; }
.muted { color: #6b7280; font-size: 0.95rem; } .muted { color: var(--muted); font-size: 0.95rem; }
.card { margin-top: 16px; padding: 16px; background: #fff; border-radius: 10px; border: 1px solid #e5e7eb; } .card { margin-top: 16px; padding: 16px; background: var(--card); border-radius: 12px; border: 1px solid var(--line); }
form { display: grid; gap: 10px; } form { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-weight: 600; } label { display: grid; gap: 6px; font-weight: 600; }
input, button { font: inherit; padding: 8px 10px; border-radius: 6px; } input, button { font: inherit; padding: 8px 10px; border-radius: 8px; }
input { border: 1px solid #d1d5db; } input { border: 1px solid var(--line); background: #fff; }
button { border: none; background: #1f2933; color: #fff; cursor: pointer; } button { border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.secondary { background: #6b7280; } button.secondary { background: transparent; color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; } table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #e5e7eb; vertical-align: top; } th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
progress { width: 100%; height: 12px; } progress { width: 100%; height: 12px; accent-color: var(--accent); }
.actions { display: grid; gap: 6px; } .actions { display: grid; gap: 6px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef2f7; } .pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; }
</style> </style>
</head> </head>
<body> <body>
@@ -403,7 +406,7 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => {
<button type="submit" class="secondary">Löschen</button> <button type="submit" class="secondary">Löschen</button>
</form> </form>
<form method="post" action="${baseUrl(`/files/${item.id}/extend`)}"> <form method="post" action="${baseUrl(`/files/${item.id}/extend`)}">
<input name="extendSeconds" placeholder="Sekunden hinzufügen" /> <input name="extendHours" placeholder="Stunden hinzufügen" />
<button type="submit">Verlängern</button> <button type="submit">Verlängern</button>
</form> </form>
</td> </td>
@@ -430,8 +433,8 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => {
<input type="file" name="file" required /> <input type="file" name="file" required />
</label> </label>
<label> <label>
Aufbewahrung (Sekunden) Aufbewahrung (Stunden)
<input name="retentionSeconds" placeholder="${uploadTtlSeconds}" /> <input name="retentionHours" placeholder="${uploadTtlSeconds / 3600}" />
</label> </label>
<button type="submit">Hochladen</button> <button type="submit">Hochladen</button>
<progress id="upload-progress" value="0" max="100"></progress> <progress id="upload-progress" value="0" max="100"></progress>
@@ -504,9 +507,9 @@ app.post(`${basePath}/api/upload`, requireAuthApi, upload.single('file'), async
const storedName = `_${token}${ext}`; const storedName = `_${token}${ext}`;
const storedPath = path.join(shareDir, storedName); const storedPath = path.join(shareDir, storedName);
const retentionOverride = parseInt(req.body.retentionSeconds || '', 10); const retentionOverride = parseFloat(req.body.retentionHours || '');
const retentionSeconds = Number.isFinite(retentionOverride) && retentionOverride > 0 const retentionSeconds = Number.isFinite(retentionOverride) && retentionOverride > 0
? retentionOverride ? Math.round(retentionOverride * 3600)
: uploadTtlSeconds; : uploadTtlSeconds;
try { try {
@@ -565,9 +568,9 @@ app.post(`${basePath}/files/:id/extend`, requireAuthPage, async (req, res) => {
return; return;
} }
const override = parseInt(req.body.extendSeconds || '', 10); const override = parseFloat(req.body.extendHours || '');
const extensionSeconds = Number.isFinite(override) && override > 0 const extensionSeconds = Number.isFinite(override) && override > 0
? override ? Math.round(override * 3600)
: uploadTtlSeconds; : uploadTtlSeconds;
const base = Math.max(uploadEntry.expires_at, Date.now()); const base = Math.max(uploadEntry.expires_at, Date.now());