import { BadRequestException, Controller, Get, ParseIntPipe, Query } from '@nestjs/common';
import { RoutesService } from './routes.service';
import { CurrentUser } from '../../common/decorators/auth.decorators';
import type { AuthUser } from '@vihar/shared';

@Controller('routes')
export class RoutesController {
  constructor(private readonly routes: RoutesService) {}

  @Get('walking')
  walking(
    @CurrentUser() user: AuthUser,
    @Query('from', ParseIntPipe) fromLocId: number,
    @Query('to', ParseIntPipe) toLocId: number,
  ) {
    if (!user.cityId) throw new BadRequestException('No city scope');
    return this.routes.getWalkingByLocationIds(user.cityId, fromLocId, toLocId);
  }
}
