Add ACE-Step music generation to the studio and library.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const track = getTrack(owner, id)
|
||||
assertFolderAccess(event, track.folderId)
|
||||
await deleteTrack(owner, id)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,18 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const body = await readBody<{ folderId?: string; name?: string }>(event).catch(() => ({} as { folderId?: string; name?: string }))
|
||||
const folderId = String(body?.folderId || '')
|
||||
const hasName = typeof body?.name === 'string'
|
||||
if (!folderId && !hasName) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Choose a library folder or a new name' })
|
||||
}
|
||||
const track = getTrack(owner, id)
|
||||
assertFolderAccess(event, track.folderId)
|
||||
if (folderId) {
|
||||
assertFolderExists(event, folderId)
|
||||
await moveTrack(owner, id, folderId)
|
||||
}
|
||||
if (hasName) await renameTrack(owner, id, body.name || '')
|
||||
return publicLibrary(event)
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
import { existsSync } from 'node:fs'
|
||||
import { sendPathWithRange } from '~/server/utils/httpRange'
|
||||
import { musicContentType } from '~/utils/music'
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const { owner } = assertLibraryOwner(event)
|
||||
const id = String(getRouterParam(event, 'id') || '')
|
||||
const track = getTrack(owner, id)
|
||||
assertFolderAccess(event, track.folderId)
|
||||
const path = trackAudioPath(owner, track.id, track.ext)
|
||||
if (!existsSync(path)) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Audio file is missing' })
|
||||
}
|
||||
const ext = track.ext || 'flac'
|
||||
return sendPathWithRange(event, path, musicContentType(ext), {
|
||||
'Content-Disposition': `inline; filename="${safeDownloadName(track.name)}.${ext}"`,
|
||||
'Cache-Control': 'private, max-age=0, must-revalidate'
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user