import { d as defineEventHandler } from '../../nitro/nitro.mjs';
import { promises } from 'fs';
import path from 'path';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';

const galerie_get = defineEventHandler(async (event) => {
  try {
    const galerieDir = path.join(process.cwd(), "public", "galerie");
    try {
      await promises.access(galerieDir);
    } catch {
      return [];
    }
    const dateien = await promises.readdir(galerieDir);
    const erlaubteExtensions = [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"];
    const bilder = dateien.filter((datei) => {
      const ext = path.extname(datei).toLowerCase();
      return erlaubteExtensions.includes(ext);
    });
    return bilder.map((filename) => {
      const nameWithoutExt = path.parse(filename).name;
      const title = nameWithoutExt.replace(/[-_]/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
      return {
        filename,
        title
      };
    });
  } catch (error) {
    console.error("Fehler beim Lesen der Galerie:", error);
    return [];
  }
});

export { galerie_get as default };
//# sourceMappingURL=galerie.get.mjs.map
