From e2a433593774f8f630900de4b67bce00db666b6f Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 17 Aug 2024 17:12:05 +0200 Subject: [PATCH] Define endpoint in TSy way --- src/routes/names/+server.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/routes/names/+server.ts b/src/routes/names/+server.ts index c0adecf..6c7a633 100644 --- a/src/routes/names/+server.ts +++ b/src/routes/names/+server.ts @@ -1,12 +1,11 @@ import { storagePath } from '$lib'; import { json } from '@sveltejs/kit'; import { readdirSync, statSync } from 'fs'; +import type { RequestHandler } from './$types'; -export function GET() { - const names = readdirSync(storagePath).filter((f) => - statSync(`${storagePath}/${f}`).isDirectory() - ); - names.sort(); +export const GET: RequestHandler = () => { + let names = readdirSync(storagePath).filter((f) => statSync(`${storagePath}/${f}`).isDirectory()); + names = names.toSorted(); return json(names); -} +};