api: update /api/best_audio route error handling

This commit is contained in:
SmilerRyan 2024-09-02 05:16:11 +01:00 committed by GitHub
parent c98b0eb120
commit a2eb743222
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -145,6 +145,13 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
app.get('/api/best_audio', async (req, res) => {
const lang = languageCode(req);
const fail = (t) => {
const { status, body } = createResponse("error", { t: loc(lang, t) });
res.status(status).json(body);
}
if (!req.query.url) { return res.status(400).send('Missing required "url" query parameter'); }
const request = req.query;
@ -168,7 +175,7 @@ export function runAPI(express, app, gitCommit, gitBranch, __dirname) {
fail('ErrorSomethingWentWrong');
}
})
app.get('/api/stream', (req, res) => {
const id = String(req.query.id);
const exp = String(req.query.exp);