Add Galerie Controller

This commit is contained in:
2026-05-04 20:59:09 +02:00
parent e9a0e12276
commit 623cdc6c37
6 changed files with 828 additions and 1 deletions
+49
View File
@@ -0,0 +1,49 @@
import { Injectable } from "@nestjs/common";
import { promises as fs } from 'fs';
import * as path from 'path';
@Injectable()
export class GalerieService {
private readonly imagesPath = "/bilder";
constructor(
){}
async getBilder(
event: string,
jahr: string
): Promise<string[]> {
const files= await fs.readdir(path.join(this.imagesPath,event, jahr));
// Nur Bilddateien filtern
const imageFiles = files.filter(file =>
/\.(jpg|jpeg|png|gif|webp)$/i.test(file)
);
return imageFiles;
}
async getJahre(
event: string
): Promise<string[]> {
const files= await fs.readdir(path.join(this.imagesPath,event));
// Nur Verzeichnisse filtern (Jahre)
const directories: string[] = [];
for (const file of files) {
const filePath = path.join(this.imagesPath, event, file);
const stat = await fs.stat(filePath);
if (stat.isDirectory()) {
directories.push(file);
}
}
return directories;
}
async getBild(
) {
}
}