feat: deselect all button, static serving for production, cloudflare tunnel setup
This commit is contained in:
@@ -7,11 +7,13 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
|
||||
import { join, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { config } from 'dotenv';
|
||||
import serveStatic from 'serve-static';
|
||||
|
||||
config();
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const DATA_DIR = join(__dirname, 'data');
|
||||
const DIST_DIR = join(__dirname, '..', 'dist');
|
||||
mkdirSync(DATA_DIR, { recursive: true });
|
||||
|
||||
const app = express();
|
||||
@@ -240,6 +242,14 @@ app.get('/api/analytics/stats', (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
// ============ STATIC FILES + SPA FALLBACK ============
|
||||
app.use(serveStatic(DIST_DIR));
|
||||
app.get('*', (req, res) => {
|
||||
if (!req.path.startsWith('/api')) {
|
||||
res.sendFile(join(DIST_DIR, 'index.html'));
|
||||
}
|
||||
});
|
||||
|
||||
// ============ START ============
|
||||
const PORT = process.env.PORT || 3052;
|
||||
app.listen(PORT, () => { console.log(`StackPilot API running on port ${PORT}`); });
|
||||
app.listen(PORT, () => { console.log(`StackPilot running on port ${PORT}`); });
|
||||
|
||||
Reference in New Issue
Block a user