feat: add configurable video AI links
This commit is contained in:
+20
@@ -349,6 +349,23 @@ async function handleHealth(req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
function handleConfig(req, res) {
|
||||
let videoAiLinks = [];
|
||||
const envLinks = process.env.VIDEO_AI_LINKS || '';
|
||||
if (envLinks.trim()) {
|
||||
// Expected format: "Kling AI=https://klingai.com,Luma=https://lumalabs.ai"
|
||||
videoAiLinks = envLinks.split(',').map(part => {
|
||||
const idx = part.indexOf('=');
|
||||
if (idx > 0) {
|
||||
return { name: part.slice(0, idx).trim(), url: part.slice(idx + 1).trim() };
|
||||
}
|
||||
return null;
|
||||
}).filter(link => link !== null);
|
||||
}
|
||||
|
||||
json(res, { videoAiLinks });
|
||||
}
|
||||
|
||||
async function handleStyleRandom(req, res) {
|
||||
let body;
|
||||
try { body = await readJsonBody(req); }
|
||||
@@ -512,6 +529,9 @@ const server = createServer(async (req, res) => {
|
||||
if (req.method === 'GET' && req.url.split('?')[0] === '/api/health') {
|
||||
return handleHealth(req, res);
|
||||
}
|
||||
if (req.method === 'GET' && req.url.split('?')[0] === '/api/config') {
|
||||
return handleConfig(req, res);
|
||||
}
|
||||
if (req.method === 'POST' && req.url.split('?')[0] === '/api/generate') {
|
||||
return handleGenerate(req, res);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user