feat: deselect all button, static serving for production, cloudflare tunnel setup

This commit is contained in:
2026-08-03 23:50:06 +01:00
parent 46906c46b3
commit 0c0daf947e
6 changed files with 26 additions and 2 deletions

1
api/package-lock.json generated
View File

@@ -14,6 +14,7 @@
"express": "4.21.2",
"jsonwebtoken": "^9.0.2",
"pg": "^8.13.1",
"serve-static": "^1.16.2",
"sql.js": "^1.11.0"
}
},

View File

@@ -12,6 +12,7 @@
"express": "4.21.2",
"jsonwebtoken": "^9.0.2",
"pg": "^8.13.1",
"serve-static": "^1.16.2",
"sql.js": "^1.11.0"
}
}

View File

@@ -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}`); });