Files
DCM/server/index.js
2026-08-05 16:48:48 -05:00

24 lines
595 B
JavaScript

import express from 'express';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import apiRouter from './api.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const distDir = path.join(__dirname, '..', 'dist');
const port = process.env.PORT || 3000;
const app = express();
app.use(express.json());
app.use('/api', apiRouter);
app.use(express.static(distDir));
app.get('*', (req, res) => {
res.sendFile(path.join(distDir, 'index.html'));
});
app.listen(port, () => {
console.log(`Datacenter Modeler listening on http://localhost:${port}`);
});