refactor login page, change routes to token-based, add service classes

This commit is contained in:
2025-06-17 16:19:22 +02:00
parent 6d3e6ad047
commit 34f8fd5490
36 changed files with 405 additions and 305 deletions

View File

@@ -0,0 +1,58 @@
import { client } from '$lib/minio';
const BUCKET = 'tatort';
export const getVorgang = ({ params }) => {
const prefix = params.vorgang ? `${params.vorgang}/` : '';
const stream = client.listObjectsV2('tatort', prefix, false, '');
const result = new ReadableStream({
start(controller) {
stream.on('data', (data) => {
if (prefix === '') {
if (data.prefix)
controller.enqueue(`${JSON.stringify({ ...data, name: data.prefix.slice(0, -1) })}\n`);
return;
}
const name = data.name.slice(prefix.length);
if (name === 'config.json') return;
// zugangscode datei
if (name === '__perm__') return;
controller.enqueue(`${JSON.stringify({ ...data, name, prefix })}\n`);
});
stream.on('end', () => {
controller.close();
});
},
cancel() {
stream.destroy();
}
});
return new Response(result, {
headers: {
'content-type': 'text/event-stream'
}
});
};
export const checkIfExactDirectoryExists = (dir: string): Promise<boolean> => {
return new Promise<boolean>((resolve, reject) => {
const prefix = dir.endsWith('/') ? dir : `${dir}/`;
const stream = client.listObjectsV2(BUCKET, prefix, false, '');
stream.on('data', (obj) => {
if (obj.prefix === undefined && obj.name.startsWith(prefix)) {
stream.destroy();
resolve(true);
}
});
stream.on('error', (err) => reject(err));
stream.on('end', () => resolve(false));
});
}