import { Router } from 'express';
import { HostByIdController } from '../controllers/HostByIdController';
import { validate, validateParams } from '../middleware/validate.middleware';
import { createHostByIdBookingSchema } from '../dto/booking.dto';
import { hostUserIdParamSchema } from '../dto/host.dto';
import { hostByIdBookingRateLimit } from '../middleware/rateLimit.middleware';

const router = Router();
const controller = new HostByIdController();

/**
 * Single API: create booking if the slot is free; otherwise return availableTimes.
 * POST /v1/hosts/:userId/bookings
 */
router.post(
  '/:userId/bookings',
  validateParams(hostUserIdParamSchema),
  hostByIdBookingRateLimit,
  validate(createHostByIdBookingSchema),
  controller.createBooking,
);

export default router;
