feat: Добавлена поддержка AS и рефакторинг UI на вкладки
Publish Docker image / build-and-push (push) Successful in 1m38s

This commit is contained in:
2025-07-07 15:37:26 +07:00
parent 92684736f9
commit f110f53a52
3 changed files with 294 additions and 228 deletions
+50
View File
@@ -76,6 +76,56 @@ app.post('/api/domains', async (req, res) => {
}
});
// --- ASNs Routes ---
// Get ASNs from S3
app.get('/api/asns', async (req, res) => {
const params = {
Bucket: BUCKET_NAME,
Key: 'asns.txt',
};
try {
const data = await s3.getObject(params).promise();
const fileContent = data.Body.toString('utf-8');
const asns = fileContent.split('\n').filter(line => line).map(line => {
const parts = line.trim().split(/\s+/);
const domain = parts[0] || ''; // Keep name 'domain' for consistency in component
const type = parts[1] || '';
return { domain, type };
});
res.json(asns);
} catch (error) {
if (error.code === 'NoSuchKey') {
res.json([]);
} else {
console.error(error);
res.status(500).send('Error reading from S3');
}
}
});
// Update ASNs in S3
app.post('/api/asns', async (req, res) => {
const { domains: asns } = req.body; // Keep name 'domains' for consistency
const fileContent = asns.map(a => `${a.domain} ${a.type}`).join('\n');
const params = {
Bucket: BUCKET_NAME,
Key: 'asns.txt',
Body: fileContent,
ContentType: 'text/plain',
};
try {
await s3.putObject(params).promise();
res.send('File updated successfully');
} catch (error) {
console.error(error);
res.status(500).send('Error writing to S3');
}
});
// The "catchall" handler: for any request that doesn't
// match one above, send back React's index.html file.
app.get('*', (req, res) => {