Deploy to Production / Build & Verify (push) Failing after 5m53s
Ping Search Engines / Notify Search Engines (push) Successful in 6s
Deploy to Production / Pre-Deploy Tests (push) Has been skipped
Deploy to Production / Deploy to Railway (push) Has been skipped
Deploy to Production / Deploy to Render (push) Has been skipped
Deploy to Production / Deploy to VPS (PM2) (push) Has been skipped
Deploy to Production / Deploy to Fly.io (push) Has been skipped
Deploy to Production / Post-Deploy Verification (push) Has been skipped
Deploy to Production / Notify on Failure (push) Successful in 2s
E2E Test Suite / Critical User Journeys (push) Has been skipped
E2E Test Suite / API Integration Tests (push) Has been skipped
E2E Test Suite / Smoke Tests (P0) (push) Failing after 9m57s
E2E Test Suite / Form Interaction Tests (push) Failing after 12m47s
E2E Test Suite / Destructive & Chaos Tests (push) Failing after 12m18s
E2E Test Suite / Cross-Browser Regression (chromium) (push) Failing after 9m54s
E2E Test Suite / Cross-Browser Regression (firefox) (push) Failing after 11m31s
E2E Test Suite / Cross-Browser Regression (webkit) (push) Failing after 16m26s
E2E Test Suite / Security Header Tests (push) Failing after 7m57s
E2E Test Suite / Test Report Summary (push) Failing after 4s
E2E Test Suite / Mobile Device Tests (push) Failing after 3h11m8s
Uptime Monitor / SSL Certificate (push) Successful in 2s
Uptime Monitor / Health & Response Time (push) Successful in 3s
Uptime Monitor / Send Alerts (push) Has been skipped
Uptime Monitor / Record Uptime Success (push) Successful in 2s
78 lines
2.5 KiB
JavaScript
78 lines
2.5 KiB
JavaScript
import { config } from 'dotenv';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, join } from 'path';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
// Load .env from the project root (same dir as server.mjs)
|
|
config({ path: join(__dirname, '.env') });
|
|
console.log('[server] Loaded .env from:', join(__dirname, '.env'));
|
|
console.log('[server] SMTP_HOST:', process.env.SMTP_HOST || 'NOT SET');
|
|
console.log('[server] CONTACT_EMAIL_TO:', process.env.CONTACT_EMAIL_TO || 'NOT SET');
|
|
|
|
import { handler as ssrHandler } from './dist/server/entry.mjs';
|
|
import express from 'express';
|
|
import compression from 'compression';
|
|
|
|
const app = express();
|
|
|
|
// Server configuration
|
|
const HOST = process.env.HOST || '0.0.0.0';
|
|
const PORT = process.env.PORT || 10000;
|
|
|
|
// Gzip/Brotli compression - reduces transfer size by ~70%
|
|
app.use(compression({
|
|
level: 6, // balanced speed/compression ratio
|
|
threshold: 1024, // only compress responses > 1KB
|
|
filter: (req, res) => {
|
|
// Don't compress already-compressed formats
|
|
if (req.headers['x-no-compression']) return false;
|
|
return compression.filter(req, res);
|
|
},
|
|
}));
|
|
|
|
// Serve static assets with long-term caching
|
|
// Hashed assets (_assets/) get 1-year immutable cache
|
|
// Non-hashed assets get 1-hour cache with revalidation
|
|
app.use('/_assets', express.static(join(__dirname, 'dist', 'client', '_assets'), {
|
|
maxAge: '1y',
|
|
immutable: true,
|
|
etag: false,
|
|
}));
|
|
|
|
app.use(express.static(join(__dirname, 'dist', 'client'), {
|
|
maxAge: '1h',
|
|
setHeaders: (res, filePath) => {
|
|
// Fonts: long-term cache since they're versioned by Google Fonts
|
|
if (/\.(woff2?|ttf|otf|eot)$/.test(filePath)) {
|
|
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
|
|
}
|
|
// Images: 1 week cache
|
|
if (/\.(jpg|jpeg|png|gif|webp|avif|svg|ico)$/.test(filePath)) {
|
|
res.setHeader('Cache-Control', 'public, max-age=604800, stale-while-revalidate=86400');
|
|
}
|
|
},
|
|
}));
|
|
|
|
// Use the Astro SSR handler for all routes
|
|
app.use(ssrHandler);
|
|
|
|
// Start the server
|
|
app.listen(PORT, HOST, () => {
|
|
console.log(`🚀 Server running at http://${HOST}:${PORT}`);
|
|
console.log(`📁 Serving static files from: ${join(__dirname, 'dist', 'client')}`);
|
|
console.log(`⚙️ Environment: ${process.env.NODE_ENV || 'development'}`);
|
|
});
|
|
|
|
// Graceful shutdown
|
|
process.on('SIGTERM', () => {
|
|
console.log('SIGTERM received, shutting down gracefully...');
|
|
process.exit(0);
|
|
});
|
|
|
|
process.on('SIGINT', () => {
|
|
console.log('SIGINT received, shutting down gracefully...');
|
|
process.exit(0);
|
|
});
|