carnet panel2

This commit is contained in:
alma 2025-04-20 16:47:15 +02:00
parent e64a54c929
commit 947d3f048f

View File

@ -47,28 +47,34 @@ export async function GET(request: Request) {
const client = createClient({
username: credentials.username,
password: credentials.password,
baseURL: normalizedBaseURL,
baseURL: `${normalizedBaseURL}/remote.php/dav/files/${credentials.username}/Private`,
authType: 'basic',
});
// Construct the folder path with leading slash
const folderPath = `/remote.php/dav/files/${credentials.username}/Private/${folder}`;
// Construct the folder path without leading slash
const folderPath = folder;
console.log('Full folder path:', folderPath);
// List files in the specified folder
const files = await client.getDirectoryContents(folderPath);
console.log('Found files:', files.length);
try {
// List files in the specified folder
const files = await client.getDirectoryContents(folderPath);
console.log('Found files:', files.length);
// Filter for .md files and format the response
const markdownFiles = files
.filter((file: any) => file.basename.endsWith('.md'))
.map((file: any) => ({
id: file.filename,
title: file.basename.replace('.md', ''),
lastModified: new Date(file.lastmod).toISOString(),
size: file.size,
}));
// Filter for .md files and format the response
const markdownFiles = files
.filter((file: any) => file.basename.endsWith('.md'))
.map((file: any) => ({
id: file.filename,
title: file.basename.replace('.md', ''),
lastModified: new Date(file.lastmod).toISOString(),
size: file.size,
}));
return NextResponse.json(markdownFiles);
return NextResponse.json(markdownFiles);
} catch (error) {
console.error('Error listing directory contents:', error);
return NextResponse.json({ error: 'Failed to list directory contents' }, { status: 500 });
}
} catch (error) {
console.error('Error fetching files:', error);
return NextResponse.json({ error: 'Failed to fetch files' }, { status: 500 });