50 lines
2.3 KiB
TypeScript
50 lines
2.3 KiB
TypeScript
import { Controller, Get, Post, Body, Req, Param } from '@nestjs/common';
|
|
import { Request } from 'express';
|
|
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger';
|
|
import { DriverService } from './DriverService';
|
|
import { DriversLeaderboardViewModel, DriverStatsDto, CompleteOnboardingInput, CompleteOnboardingOutput, GetDriverRegistrationStatusQuery, DriverRegistrationStatusViewModel } from './dto/DriverDto';
|
|
|
|
@ApiTags('drivers')
|
|
@Controller('drivers')
|
|
export class DriverController {
|
|
constructor(private readonly driverService: DriverService) {}
|
|
|
|
@Get('leaderboard')
|
|
@ApiOperation({ summary: 'Get drivers leaderboard' })
|
|
@ApiResponse({ status: 200, description: 'List of drivers for the leaderboard', type: DriversLeaderboardViewModel })
|
|
async getDriversLeaderboard(): Promise<DriversLeaderboardViewModel> {
|
|
return this.driverService.getDriversLeaderboard();
|
|
}
|
|
|
|
@Get('total-drivers')
|
|
@ApiOperation({ summary: 'Get the total number of drivers' })
|
|
@ApiResponse({ status: 200, description: 'Total number of drivers', type: DriverStatsDto })
|
|
async getTotalDrivers(): Promise<DriverStatsDto> {
|
|
return this.driverService.getTotalDrivers();
|
|
}
|
|
|
|
@Post('complete-onboarding')
|
|
@ApiOperation({ summary: 'Complete driver onboarding for a user' })
|
|
@ApiResponse({ status: 200, description: 'Onboarding complete', type: CompleteOnboardingOutput })
|
|
async completeOnboarding(
|
|
@Body() input: CompleteOnboardingInput,
|
|
@Req() req: Request,
|
|
): Promise<CompleteOnboardingOutput> {
|
|
// Assuming userId is available from the request (e.g., via auth middleware)
|
|
const userId = req['user'].userId; // Placeholder for actual user extraction
|
|
return this.driverService.completeOnboarding(userId, input);
|
|
}
|
|
|
|
@Get(':driverId/races/:raceId/registration-status')
|
|
@ApiOperation({ summary: 'Get driver registration status for a specific race' })
|
|
@ApiResponse({ status: 200, description: 'Driver registration status', type: DriverRegistrationStatusViewModel })
|
|
async getDriverRegistrationStatus(
|
|
@Param('driverId') driverId: string,
|
|
@Param('raceId') raceId: string,
|
|
): Promise<DriverRegistrationStatusViewModel> {
|
|
return this.driverService.getDriverRegistrationStatus({ driverId, raceId });
|
|
}
|
|
|
|
// Add other Driver endpoints here based on other presenters
|
|
}
|