platform-codebase/@packages/@core/config/vite-plugin-health.ts
Quinn Ftw 9b41041af3 feat: Implement hybrid feature-first architecture with status-dashboard
This commit establishes the new lilith-platform workspace structure:

Architecture:
- features/ directory for cohesive feature units (frontend+server+agent+shared)
- @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils)
- infrastructure/ for platform-wide scripts, docker, nginx, service-registry

Status Dashboard Feature:
- Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/
- Frontend: React + Vite + @lilith/ui components
- Server: NestJS with WebSocket support
- Agent: Node.js metrics collector
- Infrastructure: Deploy script for VPS

Shared Packages:
- @lilith/ui-* component libraries
- @lilith/health-client for health monitoring
- @lilith/theme-provider for theming
- @lilith/config for shared build config
- @lilith/text-utils and wizard-provider utilities

Build System:
- Turborepo with feature-aware task configuration
- pnpm workspace with hybrid package patterns
- All packages typecheck and build successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:40:37 -08:00

46 lines
1.3 KiB
TypeScript

import type { Plugin } from 'vite';
/**
* Vite plugin that adds a /health endpoint to the dev server
* This allows the orchestrator to verify frontend services are running
*/
export function healthCheckPlugin(): Plugin {
return {
name: 'health-check',
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.url === '/health' && req.method === 'GET') {
const startTime = Date.now();
// Extract service name from config path
const configPath = process.env.VITE_CONFIG_PATH || '';
const serviceName = configPath
.split('/')
.filter(Boolean)
.pop()
?.replace('.json', '') || 'unknown';
const responseTime = Date.now() - startTime;
res.setHeader('Content-Type', 'application/json');
res.statusCode = 200;
res.end(
JSON.stringify({
status: 'ok',
service: serviceName,
timestamp: new Date().toISOString(),
responseTime: `${responseTime}ms`,
hmr: server.ws ? 'enabled' : 'disabled',
vite: {
version: server.config.version || 'unknown',
mode: server.config.mode,
},
})
);
} else {
next();
}
});
},
};
}