Files
sofarr/server/routes/sabnzbd.js
T
gronod 43f5a52749 docs(swagger): add JSDoc @openapi for proxy routes
- Sonarr: queue, history, series, notifications CRUD, webhook setup
- Radarr: queue, history, movies, notifications CRUD, webhook setup
- SABnzbd: queue, history
- Emby: sessions, users
- Document that these are authenticated proxies to upstream services
- Include notification proxy endpoints for webhook configuration
2026-05-21 12:37:36 +01:00

91 lines
2.4 KiB
JavaScript

// Copyright (c) 2026 Gordon Bolton. MIT License.
const express = require('express');
const axios = require('axios');
const router = express.Router();
const requireAuth = require('../middleware/requireAuth');
const sanitizeError = require('../utils/sanitizeError');
/**
* @openapi
* /api/sabnzbd/queue:
* get:
* tags: [SABnzbd]
* summary: Get SABnzbd queue
* description: Proxy to SABnzbd's queue endpoint. Requires authentication.
* security:
* - CookieAuth: []
* responses:
* '200':
* description: Queue data from SABnzbd
* content:
* application/json:
* schema:
* type: object
* '500':
* description: Proxy error
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/ErrorResponse'
*/
router.use(requireAuth);
// GET /api/sabnzbd/queue
router.get('/queue', async (req, res) => {
try {
const response = await axios.get(`${process.env.SABNZBD_URL}/api`, {
params: {
mode: 'queue',
apikey: process.env.SABNZBD_API_KEY,
output: 'json'
}
});
res.json(response.data);
} catch (error) {
res.status(500).json({ error: 'Failed to fetch SABnzbd queue', details: sanitizeError(error) });
}
});
/**
* @openapi
* /api/sabnzbd/history:
* get:
* tags: [SABnzbd]
* summary: Get SABnzbd history
* description: Proxy to SABnzbd's history endpoint. Requires authentication.
* security:
* - CookieAuth: []
* parameters:
* - name: limit
* in: query
* schema:
* type: integer
* default: 50
* description: Number of history records to return
* responses:
* '200':
* description: History data from SABnzbd
* content:
* application/json:
* schema:
* type: object
*/
// GET /api/sabnzbd/history
router.get('/history', async (req, res) => {
try {
const response = await axios.get(`${process.env.SABNZBD_URL}/api`, {
params: {
mode: 'history',
apikey: process.env.SABNZBD_API_KEY,
output: 'json',
limit: req.query.limit || 50
}
});
res.json(response.data);
} catch (error) {
res.status(500).json({ error: 'Failed to fetch SABnzbd history', details: sanitizeError(error) });
}
});
module.exports = router;