27 lines
878 B
JavaScript
27 lines
878 B
JavaScript
const express = require('express');
|
|
const os = require('os');
|
|
const { getContainerData } = require('./utils/dockerInspector');
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 8686;
|
|
const hostname = os.hostname().toLowerCase(); // used in domain mapping
|
|
|
|
// Endpoint to list all containers and their info
|
|
app.get('/containers', async (req, res) => {
|
|
try {
|
|
const containers = await getContainerData();
|
|
res.setHeader('Content-Type', 'application/json');
|
|
res.send(JSON.stringify(containers, null, 2)); // Pretty print JSON
|
|
} catch (err) {
|
|
console.error('Error fetching containers:', err);
|
|
res.status(500).send('Internal Server Error');
|
|
}
|
|
});
|
|
|
|
const domainRoutes = require('./routes/domains');
|
|
app.use('/domains', domainRoutes);
|
|
|
|
// Start server
|
|
app.listen(8686, '0.0.0.0', () => {
|
|
console.log('Infra API listening at http://localhost:8686');
|
|
}); |