import express from 'express';
import cors from 'cors';
import { gameRoutes, lobbyRoutes, playerRoutes, questionRoutes, rootRoutes } from './routes';
import { createLogger } from './utils/logger';
import { errorHandler, requestLogger } from './middleware';
import path from 'path';

const logger = createLogger('server');
const app = express();

logger.info('Starting server...');

app.use(cors());
app.use(express.json());
app.use(errorHandler);
app.use(requestLogger);

app.use('/assets', express.static(path.join(__dirname, 'assets')));

app.use('/', rootRoutes);
app.use('/lobbies', lobbyRoutes);
app.use('/player', playerRoutes);
app.use('/questions', questionRoutes);
app.use('/game', gameRoutes);

app.listen(3000, () => logger.info('Server running on port 3000'));
