From 4dffb86ca8ddbe7089ce124443cfb317a9548765 Mon Sep 17 00:00:00 2001 From: Ender Date: Thu, 23 Oct 2025 23:03:19 +0200 Subject: [PATCH] chore(api): harden /api/media/audio with config checks and clearer errors --- apps/api/src/media.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/api/src/media.ts b/apps/api/src/media.ts index 5fd7157..4f28d4d 100644 --- a/apps/api/src/media.ts +++ b/apps/api/src/media.ts @@ -11,6 +11,12 @@ router.post('/audio', upload.single('audio'), async ( res: express.Response ) => { try { + const { S3_ENDPOINT, S3_ACCESS_KEY, S3_SECRET_KEY } = process.env; + if (!S3_ENDPOINT || !S3_ACCESS_KEY || !S3_SECRET_KEY) { + console.error('Upload failed: missing S3 config (S3_ENDPOINT/S3_ACCESS_KEY/S3_SECRET_KEY)'); + return res.status(500).json({ error: 'Object storage not configured' }); + } + if (!req.file) return res.status(400).json({ error: 'No audio file' }); const bucket = process.env.S3_BUCKET || 'voxblog';