Define endpoint in TSy way
This commit is contained in:
parent
3160923f7e
commit
e2a4335937
@ -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);
|
||||||
}
|
};
|
||||||
|
Reference in New Issue
Block a user