Files
evilspins/server/api/playlists/index.ts
valere 83459227aa
All checks were successful
Deploy App / build (push) Successful in 1m9s
Deploy App / deploy (push) Successful in 16s
add folder for playlists api 2
2025-10-04 01:13:38 +02:00

23 lines
533 B
TypeScript

import fs from 'fs'
import path from 'path'
import { eventHandler } from 'h3'
export default eventHandler(async (event) => {
const directoryPath = path.join(process.cwd(), '/mnt/media/files/music')
try {
// Read the directory contents
const files = await fs.promises.readdir(directoryPath)
return {
success: true,
files: files.filter(file => !file.startsWith('.')).reverse() // exclude unwanted files
}
} catch (error) {
return {
success: false,
error: error.message
}
}
})