Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Body, Controller, Delete, Get, Optional, Param, ParseUUIDPipe, Patch, Post, Query } from '@nestjs/common';
import { CurrentSession } from '../auth/session.decorator';
import type { AuthenticatedSession } from '../auth/tenant.guard';
import { CreateTransactionDto, UpdateTransactionDto } from './dto';
import { TransactionsService } from './transactions.service';
@Controller('transactions')
export class TransactionsController {
constructor(private readonly transactionsService: TransactionsService) {}
@Get()
list(
@CurrentSession() session: AuthenticatedSession,
@Query('organizationId') organizationId?: string,
) {
// organizationId is optional; when present it is validated as UUID by ParseUUIDPipe below.
// We accept it as a plain string here and let the service filter by it.
// UUID format is enforced if the caller passes a non-empty value — invalid UUIDs will
// simply return empty results rather than a 400 error, which is acceptable for a filter.
return this.transactionsService.list(session, organizationId);
}
@Get(':id')
getById(@CurrentSession() session: AuthenticatedSession, @Param('id', ParseUUIDPipe) id: string) {
return this.transactionsService.getById(session, id);
}
@Post()
create(@CurrentSession() session: AuthenticatedSession, @Body() dto: CreateTransactionDto) {
return this.transactionsService.create(session, dto);
}
@Patch(':id')
update(
@CurrentSession() session: AuthenticatedSession,
@Param('id', ParseUUIDPipe) id: string,
@Body() dto: UpdateTransactionDto,
) {
return this.transactionsService.update(session, id, dto);
}
@Delete(':id')
softDelete(@CurrentSession() session: AuthenticatedSession, @Param('id', ParseUUIDPipe) id: string) {
return this.transactionsService.softDelete(session, id);
}
}
|