import { FastifyInstance } from 'fastify';
import { getRooms, getRoomById, createRoom } from '../controllers/rooms.controller';

export async function roomRoutes(server: FastifyInstance) {
    server.addHook('onRequest', async (request) => {
        try {
            await request.jwtVerify();
        } catch (err) {
            // Allow public access for now if needed, or enforce strict
            // For Phase 1, strict auth except maybe seeded user
            // server.log.error(err);
            throw err;
        }
    });

    server.get('/', getRooms);
    server.get('/:id', getRoomById);
    server.post('/', createRoom);
}
