Define endpoint in TSy way
All checks were successful
/ Misc Linters (push) Successful in 25s
/ Build App (push) Successful in 52s

This commit is contained in:
Valentin Brandl 2024-08-17 17:12:05 +02:00
parent 3160923f7e
commit e2a4335937
Signed by: vbrandl
GPG Key ID: CAD4DA1A789125F9

View File

@ -1,12 +1,11 @@
import { storagePath } from '$lib'; import { storagePath } from '$lib';
import { json } from '@sveltejs/kit'; import { json } from '@sveltejs/kit';
import { readdirSync, statSync } from 'fs'; import { readdirSync, statSync } from 'fs';
import type { RequestHandler } from './$types';
export function GET() { export const GET: RequestHandler = () => {
const names = readdirSync(storagePath).filter((f) => let names = readdirSync(storagePath).filter((f) => statSync(`${storagePath}/${f}`).isDirectory());
statSync(`${storagePath}/${f}`).isDirectory() names = names.toSorted();
);
names.sort();
return json(names); return json(names);
} };