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 type { User } from '../../types';
import { AddonGuard } from '../addons/addon.guard';
import { RequireAddon } from '../addons/require-addon.decorator';
import { CurrentUser } from '../auth-core/current-user.decorator';
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
import { ResponseContract } from '../common/response-contract';
import { rowId } from '../common/row-id.pipe';
import { JourneyMapService } from './journey-map.service';
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { journeyMapLayersResponseSchema } from '@trek/shared';

/**
 * GET /api/journeys/:id/map-layers (JRN-04): the plan, the routes and the
 * stays the journey map can show beside its entries, each source answering on
 * its own. Read-only and derived, like `/tracks`; the journey's own access
 * applies, a stranger gets the same 404 as for the journey itself.
 */
@Controller('api/journeys')
@UseGuards(AddonGuard, JwtAuthGuard)
@RequireAddon(ADDON_IDS.JOURNEY, 'Journey')
export class JourneyMapController {
  constructor(private readonly map: JourneyMapService) {}

  @Get(':id/map-layers')
  @ResponseContract(journeyMapLayersResponseSchema)
  async layers(@CurrentUser() user: User, @Param('id', rowId('Journey not found')) id: number) {
    return this.map.mapLayers(id, user.id);
  }
}