FEAT: api for playlists v1

This commit is contained in:
valere
2024-10-28 13:59:38 +01:00
parent 8d3586f4d4
commit 0ca4cc3bfe
2 changed files with 1 additions and 21 deletions

1
.gitignore vendored
View File

@@ -17,3 +17,4 @@ logs
.DS_Store
.fleet
.idea
media

View File

@@ -1,21 +0,0 @@
import fs from 'fs'
import path from 'path'
export default eventHandler(async (event) => {
const directoryPath = path.join(process.cwd(), 'media/files/music') // replace 'your-folder' with the folder you want to list
try {
// Read the directory contents
const files = await fs.promises.readdir(directoryPath)
return {
success: true,
files: files.filter(file => !file.startsWith('.')) // optional: exclude unwanted files
}
} catch (error) {
return {
success: false,
error: error.message
}
}
})