refactoring magic strings in upload actions
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user