import 'dotenv/config';
import Fastify from 'fastify';
import cors from '@fastify/cors';
import { curriculumRoutes } from './routes/curriculum.js';
import { employeeRoutes } from './routes/employee.js';

const app = Fastify({ logger: true });

await app.register(cors, { origin: true });
await app.register(curriculumRoutes);
await app.register(employeeRoutes);

const port = parseInt(process.env['CURRICULUM_PORT'] ?? '3003', 10);

try {
  await app.listen({ port, host: '0.0.0.0' });
} catch (err) {
  app.log.error(err);
  process.exit(1);
}
