This commit is contained in:
@ -1,12 +1,10 @@
|
||||
import { writeFileSync, mkdirSync, existsSync } from 'fs';
|
||||
import { fail } from '@sveltejs/kit';
|
||||
import type { RequestEvent } from './$types';
|
||||
import safePath from '$lib';
|
||||
import safePath, { storagePath } from '$lib';
|
||||
import { hash } from 'crypto';
|
||||
import path from 'path';
|
||||
|
||||
const storagePath: string = './uploads';
|
||||
|
||||
const mkdirIfNotExists = (path: string) => {
|
||||
if (!existsSync(path)) {
|
||||
mkdirSync(path);
|
||||
|
11
src/routes/names/+server.ts
Normal file
11
src/routes/names/+server.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { storagePath } from '$lib';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { readdirSync, statSync } from 'fs';
|
||||
|
||||
export function GET() {
|
||||
const names = readdirSync(storagePath).filter((f) =>
|
||||
statSync(`${storagePath}/${f}`).isDirectory()
|
||||
);
|
||||
|
||||
return json(names);
|
||||
}
|
Reference in New Issue
Block a user