This commit is contained in:
parent
e93d7a5652
commit
ff9c0a6941
@ -1,5 +1,6 @@
|
||||
// place files you want to import through the `$lib` alias in this folder.
|
||||
|
||||
const safePath = (input: string) => input.replace(/\W/g, '');
|
||||
export const storagePath: string = './uploads';
|
||||
|
||||
export default safePath;
|
||||
|
@ -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