Production readiness, SEO enhancements, and Engine V2 upgrades

This commit is contained in:
drjones
2026-06-13 19:10:10 -07:00
parent 8333e241c6
commit 44d89d205c
34 changed files with 23521 additions and 162056 deletions

View File

@@ -43,6 +43,9 @@ export const query = {
// Initialize schema
export async function initDb() {
// Enable WAL mode for high concurrency
await query.run('PRAGMA journal_mode = WAL;');
// Users table
await query.run(`
CREATE TABLE IF NOT EXISTS users (

View File

@@ -1,5 +1,6 @@
import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
import { WebSocketServer } from 'ws';
import jwt from 'jsonwebtoken';
import bcrypt from 'bcryptjs';
@@ -23,6 +24,10 @@ initDb().catch((err) => {
});
// Middleware configuration
app.use(helmet({
contentSecurityPolicy: false,
crossOriginEmbedderPolicy: false,
}));
app.use(cors());
// Stripe Webhook needs raw body, configure other routes to use express.json()
@@ -392,7 +397,25 @@ const wss = new WebSocketServer({ server });
const rooms = new Map(); // projectRoom -> Set of ws clients
// Heartbeat to prevent memory leaks from dead connections
const interval = setInterval(() => {
wss.clients.forEach((ws) => {
if (ws.isAlive === false) return ws.terminate();
ws.isAlive = false;
ws.ping();
});
}, 30000);
wss.on('close', () => {
clearInterval(interval);
});
wss.on('connection', (ws) => {
ws.isAlive = true;
ws.on('pong', () => {
ws.isAlive = true;
});
let currentRoom = null;
let userId = null;