Skip to content

Commit 70f203d

Browse files
committed
fix: resolve TS error in fal-audio, widen music regex and fal method routing
- Fix fal-audio.ts TS2339: use already-narrowed contentType variable instead of re-accessing response.audio.contentType in ext derivation - Widen ELEVENLABS_MUSIC_RE to match /v1/music and /v1/music/{subType} (was restricted to generation|variation|remix|extend only) - Default musicSubType to "music" when regex capture group is empty - Add PUT method to fal queue requests route for cancel support
1 parent 47e8a28 commit 70f203d

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/fal-audio.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ function audioToFalFile(response: AudioResponse): Record<string, unknown> {
9494

9595
const ext =
9696
response.format ??
97-
(typeof response.audio !== "string" && response.audio.contentType
98-
? (Object.entries(FORMAT_TO_CONTENT_TYPE).find(
99-
([, v]) => v === response.audio.contentType,
100-
)?.[0] ?? "mp3")
97+
(contentType !== "audio/mpeg"
98+
? (Object.entries(FORMAT_TO_CONTENT_TYPE).find(([, v]) => v === contentType)?.[0] ?? "mp3")
10199
: "mp3");
102100

103101
const fileSize =

src/server.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const VIDEOS_PATH = "/v1/videos";
8181
const VIDEOS_STATUS_RE = /^\/v1\/videos\/([^/]+)$/;
8282
const GEMINI_PREDICT_RE = /^\/v1beta\/models\/([^:]+):predict$/;
8383
const ELEVENLABS_SOUND_GENERATION_PATH = "/v1/sound-generation";
84-
const ELEVENLABS_MUSIC_RE = /^\/v1\/music\/(generation|variation|remix|extend)$/;
84+
const ELEVENLABS_MUSIC_RE = /^\/v1\/music(?:\/(.+))?$/;
8585
const FAL_QUEUE_SUBMIT_RE = /^\/fal\/queue\/submit\/(.+)$/;
8686
const FAL_QUEUE_REQUESTS_RE = /^\/fal\/queue\/requests\/(.+)$/;
8787
const FAL_RUN_RE = /^\/fal\/run\/(.+)$/;
@@ -1645,7 +1645,7 @@ export async function createServer(
16451645
const musicMatch = pathname.match(ELEVENLABS_MUSIC_RE);
16461646
if (musicMatch && req.method === "POST") {
16471647
setCorsHeaders(res);
1648-
const musicSubType = musicMatch[1];
1648+
const musicSubType = musicMatch[1] ?? "music";
16491649
try {
16501650
const raw = await readBody(req);
16511651
const chaosResult = applyChaos(
@@ -1720,7 +1720,10 @@ export async function createServer(
17201720

17211721
// GET /fal/queue/requests/{requestId} — fal.ai Queue Status/Result
17221722
const falQueueRequestsMatch = pathname.match(FAL_QUEUE_REQUESTS_RE);
1723-
if (falQueueRequestsMatch && (req.method === "GET" || req.method === "POST")) {
1723+
if (
1724+
falQueueRequestsMatch &&
1725+
(req.method === "GET" || req.method === "POST" || req.method === "PUT")
1726+
) {
17241727
setCorsHeaders(res);
17251728
try {
17261729
const raw = req.method === "POST" ? await readBody(req) : "{}";

0 commit comments

Comments
 (0)