FEAT: api for playlists v0.1

This commit is contained in:
valere
2024-10-28 13:42:55 +01:00
parent 2de75840d2
commit 799c944e01
2 changed files with 24 additions and 1 deletions

View File

@@ -11,8 +11,10 @@ services:
LETSENCRYPT_HOST: "${DOMAIN}" LETSENCRYPT_HOST: "${DOMAIN}"
PUID: "${PUID}" PUID: "${PUID}"
PGID: "${PGID}" PGID: "${PGID}"
volumes:
- "${MEDIA_DIR}:/app/media"
networks: networks:
default: default:
name: dockerweb name: dockerweb
external: true external: true

21
server/api/playlists.ts Normal file
View File

@@ -0,0 +1,21 @@
import fs from 'fs'
import path from 'path'
export default eventHandler(async (event) => {
const directoryPath = path.join(process.cwd(), '/app/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
}
}
})