Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.3 KB
Raw Blame
import { ADDON_IDS } from '../../addons';
import { RequireAddon } from '../addons/require-addon.decorator';
import { TripAddonGuard } from '../addons/trip-addon.guard';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
import { ResponseContract } from '../common/response-contract';
import { TripAccessGuard } from '../permissions/trip-access.guard';
import { PaddleRouteRequestDto } from './paddle-routing.dto';
import { PaddleRoutingService } from './paddle-routing.service';
import { Body, Controller, HttpCode, Post, UseGuards } from '@nestjs/common';
import { paddleRouteResponseSchema } from '@trek/shared';

/**
 * POST /api/trips/:tripId/paddle/route: legs of a paddle tour planned on the
 * water (PAD-11). It reads and writes nothing of the trip; the trip in the
 * path only says whose planner asks, so anyone who can see the trip may.
 */
@Controller('api/trips/:tripId/paddle')
@UseGuards(JwtAuthGuard, TripAccessGuard, TripAddonGuard)
@RequireAddon(ADDON_IDS.TOURS, 'Tours')
export class PaddleRoutingController {
  constructor(private readonly routing: PaddleRoutingService) {}

  @Post('route')
  @HttpCode(200)
  @ResponseContract(paddleRouteResponseSchema)
  async route(@Body() body: PaddleRouteRequestDto) {
    return await this.routing.route(body);
  }
}