/**
 * Transactions Controller
 *
 * REST endpoints for transaction control
 * Replaces: StartTransaction, Commit, Rollback
 *
 * Note: REST is stateless - each request is independent.
 * For multi-step transactions, use a single endpoint that does
 * all operations in one $transaction() call.
 */
import { Controller, Post, UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';

@Controller('transactions')
@UseGuards(JwtAuthGuard)
export class TransactionsController {
  /**
   * POST /api/transactions/begin
   * Informational - actual transaction starts when you call an operation
   * that uses $transaction()
   */
  @Post('begin')
  begin() {
    return {
      message: 'Use runInTransaction or $transaction for explicit transactions',
      hint: 'Send all operations in a single request that uses $transaction internally',
    };
  }

  /**
   * POST /api/transactions/commit
   * Informational - Prisma auto-commits on successful request
   */
  @Post('commit')
  commit() {
    return { message: 'Transactions auto-commit on successful request completion' };
  }

  /**
   * POST /api/transactions/rollback
   * Informational - Prisma auto-rollbacks on error
   */
  @Post('rollback')
  rollback() {
    return { message: 'Transactions auto-rollback on error' };
  }
}
