Files
TREK/server/src/nest/journey/journey-map.controller.ts
T
Maurice 3eac508baf fix(api): parse path ids with a rowId pipe that answers like an unknown id
RowIdPipe (src/nest/common/row-id.pipe.ts) parses a path param with toRowId. It answers a refused spelling with the route's own not-found answer, so '0x5', '5e0' and 'abc' get what an id that names no row gets. ParseRowIdPipe replaces Nest's ParseIntPipe with the same 400 and message: ParseIntPipe let '-1' and numbers past 2^53 through, and Postgres refuses the latter as out of range. Journey, journey recordings, day import, book design, map, public photo, collections, doc-sync, vacay, atlas and the plugin user-data export declare their ids through it. The upload routes parse in the handler with withRowId, so a refused id takes the existing cleanup path, or carry SpoolCleanupInterceptor (collections).
2026-11-18 13:20:05 +01:00

31 lines
1.3 KiB
TypeScript

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);
}
}