37 lines
991 B
JavaScript
37 lines
991 B
JavaScript
require('dotenv').config();
|
|
|
|
const express = require('express');
|
|
const cors = require('cors');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const config = require('./config');
|
|
|
|
const app = express();
|
|
const PORT = config.port;
|
|
|
|
app.use(cors());
|
|
app.use(express.json());
|
|
app.use(express.urlencoded({ extended: true }));
|
|
|
|
const authRoutes = require('./routes/auth');
|
|
const projectRoutes = require('./routes/projects');
|
|
const deployRoutes = require('./routes/deploy');
|
|
|
|
app.use('/api/auth', authRoutes);
|
|
app.use('/api/projects', projectRoutes);
|
|
app.use('/api/deploy', deployRoutes);
|
|
|
|
if (fs.existsSync(path.join(__dirname, '../client/dist'))) {
|
|
app.use(express.static(path.join(__dirname, '../client/dist')));
|
|
app.get('*', (req, res) => {
|
|
res.sendFile(path.join(__dirname, '../client/dist/index.html'));
|
|
});
|
|
}
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`Server running on port ${PORT}`);
|
|
if (config.baseDomain) {
|
|
console.log(`Base domain: ${config.baseDomain}`);
|
|
}
|
|
});
|