JWT, server modüler hale getirildi, Torrent durumu kalıcı hale getirildi.
This commit is contained in:
38
server/modules/health.js
Normal file
38
server/modules/health.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { exec } from "child_process";
|
||||
import { promisify } from "util";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
async function checkBinary(binary) {
|
||||
try {
|
||||
const { stdout } = await execAsync(`which ${binary}`);
|
||||
const location = stdout.trim();
|
||||
return { name: binary, ok: Boolean(location), location: location || null };
|
||||
} catch (err) {
|
||||
return { name: binary, ok: false, error: err.message };
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildHealthReport({ ffmpegPath = "ffmpeg", ffprobePath = "ffprobe", tmdbKey, tvdbKey, fanartKey }) {
|
||||
const binaries = await Promise.all([
|
||||
checkBinary(ffmpegPath),
|
||||
checkBinary(ffprobePath)
|
||||
]);
|
||||
|
||||
return {
|
||||
binaries,
|
||||
apis: {
|
||||
tmdb: { configured: Boolean(tmdbKey) },
|
||||
tvdb: { configured: Boolean(tvdbKey) },
|
||||
fanart: { configured: Boolean(fanartKey) }
|
||||
},
|
||||
timestamp: new Date().toISOString()
|
||||
};
|
||||
}
|
||||
|
||||
export function healthRouter(getReport) {
|
||||
return (req, res) => {
|
||||
const report = typeof getReport === "function" ? getReport() : null;
|
||||
res.json(report || { status: "unknown" });
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user