Files
CompanySite/server.mjs
T
Clintchiz d402256547
Deploy to Production / Build & Verify (push) Failing after 5m56s
Ping Search Engines / Notify Search Engines (push) Successful in 2s
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 11m26s
E2E Test Suite / Form Interaction Tests (push) Failing after 11m42s
E2E Test Suite / Destructive & Chaos Tests (push) Failing after 12m2s
E2E Test Suite / Cross-Browser Regression (chromium) (push) Failing after 16m14s
E2E Test Suite / Cross-Browser Regression (webkit) (push) Failing after 17m45s
E2E Test Suite / Cross-Browser Regression (firefox) (push) Failing after 25m23s
E2E Test Suite / Security Header Tests (push) Failing after 7m55s
E2E Test Suite / Test Report Summary (push) Failing after 20s
E2E Test Suite / Mobile Device Tests (push) Failing after 2h49m9s
Uptime Monitor / Health & Response Time (push) Failing after 2s
Uptime Monitor / SSL Certificate (push) Successful in 2s
Uptime Monitor / Send Alerts (push) Failing after 3s
Uptime Monitor / Record Uptime Success (push) Has been skipped
First Init
2026-03-21 16:46:46 +05:30

70 lines
2.2 KiB
JavaScript

import { handler as ssrHandler } from './dist/server/entry.mjs';
import express from 'express';
import compression from 'compression';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
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);
});