Files
dd0c/products/02-iac-drift-detection/saas/src/index.ts
Max Mayfield 27a89ee2b7
Some checks failed
CI — P2 Drift (Go + Node) / agent (push) Failing after 3s
CI — P2 Drift (Go + Node) / saas (push) Successful in 29s
CI — P3 Alert / test (push) Successful in 40s
CI — P4 Portal / test (push) Successful in 32s
CI — P6 Run / saas (push) Successful in 30s
CI — P5 Cost / test (push) Successful in 46s
Trigger CI with tsc fix
2026-03-01 06:56:00 +00:00

51 lines
1.3 KiB
TypeScript

import Fastify from 'fastify';
import cors from '@fastify/cors';
import helmet from '@fastify/helmet';
import { config } from './config/index.js';
import { registerProcessorRoutes } from './processor/routes.js';
import { registerApiRoutes } from './api/routes.js';
import { createPool } from './data/db.js';
import { createRedis } from './data/redis.js';
const app = Fastify({
logger: {
level: config.logLevel,
transport: config.nodeEnv === 'development'
? { target: 'pino-pretty' }
: undefined,
},
});
async function start() {
await app.register(cors, { origin: config.corsOrigin });
await app.register(helmet);
// Data layer
const pool = createPool(config.databaseUrl);
const redis = createRedis(config.redisUrl);
// Decorate fastify instance
app.decorate('pool', pool);
app.decorate('redis', redis);
app.decorate('config', config);
// Routes
await registerProcessorRoutes(app);
await registerApiRoutes(app);
// Health
app.get('/health', async () => ({ status: 'ok' }));
await app.listen({ port: config.port, host: '0.0.0.0' });
app.log.info(`dd0c/drift SaaS listening on :${config.port}`);
}
start().catch((err) => {
console.error('Failed to start:', err);
process.exit(1);
});
export { app };
// CI: 2026-03-01T06:52:14Z
// CI fix: 06:56