refactoring magic strings in upload actions

This commit is contained in:
2025-09-29 08:42:54 +02:00
parent 387a9b21a8
commit 1d2769d114
2 changed files with 7 additions and 2 deletions

View File

@@ -9,6 +9,7 @@
import shortenFileSize from '$lib/helper/shortenFileSize.js';
import Exclamation from '$lib/icons/Exclamation.svelte';
import FileRect from '$lib/icons/File-rect.svelte';
import { ROUTE_NAMES } from '../../index.js';
export let form;
@@ -43,7 +44,7 @@
data.append('vorgang', vorgang);
data.append('name', name);
data.append('vorgangPIN', vorgangPIN);
const response = await fetch('?/validate', { method: 'POST', body: data });
const response = await fetch(ROUTE_NAMES.UPLOAD_VALIDATE, { method: 'POST', body: data });
/** @type {import('@sveltejs/kit').ActionResult} */
const result = deserialize(await response.text());
@@ -76,7 +77,7 @@
data.append('type', files[0].type);
data.append('fileName', files[0].name);
}
const response = await fetch('?/url', { method: 'POST', body: data });
const response = await fetch(ROUTE_NAMES.UPLOAD_URL, { method: 'POST', body: data });
/** @type {import('@sveltejs/kit').ActionResult} */
const result = deserialize(await response.text());
if (result.type === 'success') return result.data?.url;

View File

@@ -4,6 +4,10 @@ export const ROUTE_NAMES = {
// (angemeldet)
LIST: '/list',
UPLOAD: '/upload',
// UPLOAD actions
UPLOAD_URL: '/upload?/url',
UPLOAD_VALIDATE: '/upload?/validate',
USERMGMT: '/user-management',
// (token-based)