Some checks failed
InnoHub Processor/tatort/pipeline/head There was a failure building this commit
33 lines
789 B
TypeScript
33 lines
789 B
TypeScript
import { redirect, type ServerLoadEvent } from '@sveltejs/kit';
|
|
import type { PageServerLoad } from '../anmeldung/$types';
|
|
|
|
import { ROUTE_NAMES } from '..';
|
|
|
|
// *** [START] check for dir
|
|
|
|
import fs from 'fs';
|
|
const path = '/daten';
|
|
|
|
let path_existing: string;
|
|
|
|
fs.access(path, fs.constants.F_OK, (err) => {
|
|
if (err) {
|
|
console.error(`❌ Directory "${path}" does NOT exist or is not accessible.`);
|
|
path_existing = "NO";
|
|
} else {
|
|
console.log(`✅ Directory "${path}" exists and is accessible.`);
|
|
path_existing = "YES";
|
|
}
|
|
});
|
|
|
|
// ***
|
|
|
|
export const load: PageServerLoad = (event: ServerLoadEvent) => {
|
|
if (!event.locals.user && event.url.pathname !== ROUTE_NAMES.ANMELDUNG)
|
|
throw redirect(303, ROUTE_NAMES.ANMELDUNG);
|
|
return {
|
|
user: event.locals.user,
|
|
path_existing
|
|
};
|
|
};
|