Files
dd0c/products/05-aws-cost-anomaly/src/index.ts
Max Mayfield 68140881e0
Some checks failed
CI — P3 Alert / test (push) Failing after 15s
CI — P4 Portal / test (push) Failing after 19s
CI — P5 Cost / test (push) Failing after 17s
CI — P6 Run / saas (push) Failing after 18s
Trigger CI for P3-P6 Node products
2026-03-01 06:43:58 +00:00

36 lines
1.2 KiB
TypeScript

import Fastify from 'fastify';
import cors from '@fastify/cors';
import pino from 'pino';
import { config } from './config/index.js';
import { pool } from './data/db.js';
import { registerAuth, registerAuthRoutes } from './auth/middleware.js';
import { registerAnomalyRoutes } from './api/anomalies.js';
import { registerBaselineRoutes } from './api/baselines.js';
import { registerGovernanceRoutes } from './api/governance.js';
import { registerIngestionRoutes } from './api/ingestion.js';
const logger = pino({ name: 'dd0c-cost', level: config.LOG_LEVEL });
const app = Fastify({ logger: true });
await app.register(cors, { origin: config.CORS_ORIGIN });
registerAuth(app, config.JWT_SECRET, pool);
app.get('/health', async () => ({ status: 'ok', service: 'dd0c-cost' }));
registerAuthRoutes(app, config.JWT_SECRET, pool);
registerIngestionRoutes(app);
registerAnomalyRoutes(app);
registerBaselineRoutes(app);
registerGovernanceRoutes(app);
try {
await app.listen({ port: config.PORT, host: '0.0.0.0' });
logger.info({ port: config.PORT }, 'dd0c/cost started');
} catch (err) {
logger.fatal(err, 'Failed to start');
process.exit(1);
}
// Build: 2026-03-01T06:43:58Z