feat: Service-Editor mit vollem CRUD und Server-Speichern
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 16s
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 16s
This commit is contained in:
37
server.js
37
server.js
@@ -1218,6 +1218,43 @@ const server = http.createServer(async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.url?.startsWith('/api/services/save')) {
|
||||
if (req.method !== 'POST') {
|
||||
json(res, 405, { error: 'Method not allowed' });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await verifyAdminRequest(req);
|
||||
|
||||
const body = await new Promise((resolve, reject) => {
|
||||
let data = '';
|
||||
req.on('data', chunk => data += chunk);
|
||||
req.on('end', () => {
|
||||
try {
|
||||
resolve(JSON.parse(data));
|
||||
} catch (e) {
|
||||
reject(new Error('Invalid JSON'));
|
||||
}
|
||||
});
|
||||
req.on('error', reject);
|
||||
});
|
||||
|
||||
if (!body || !Array.isArray(body.categories) || !Array.isArray(body.services)) {
|
||||
json(res, 400, { error: 'Invalid configuration format' });
|
||||
return;
|
||||
}
|
||||
|
||||
const servicesPath = path.join(PUBLIC_DIR, 'services.json');
|
||||
await fsp.writeFile(servicesPath, JSON.stringify(body, null, 2), 'utf-8');
|
||||
|
||||
json(res, 200, { success: true, message: 'Configuration saved successfully' });
|
||||
} catch (error) {
|
||||
json(res, error.statusCode || 500, { error: error.message });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (req.url?.startsWith('/api/disks/scan-folder')) {
|
||||
if (req.method !== 'GET') {
|
||||
json(res, 405, { error: 'Method not allowed' });
|
||||
|
||||
Reference in New Issue
Block a user