This commit is contained in:
2025-12-21 22:35:38 +01:00
parent 3c64f328e2
commit 9bd2e630e6
38 changed files with 736 additions and 684 deletions

View File

@@ -1,4 +1,4 @@
import { Controller, Get, Post, Body, Req, Param } from '@nestjs/common';
import { Controller, Get, Post, Put, Body, Req, Param } from '@nestjs/common';
import { Request } from 'express';
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger';
@@ -25,16 +25,14 @@ export class DriverController {
@ApiOperation({ summary: 'Get drivers leaderboard' })
@ApiResponse({ status: 200, description: 'List of drivers for the leaderboard', type: DriversLeaderboardDTO })
async getDriversLeaderboard(): Promise<DriversLeaderboardDTO> {
const presenter = await this.driverService.getDriversLeaderboard();
return presenter.viewModel;
return await 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> {
const presenter = await this.driverService.getTotalDrivers();
return presenter.viewModel;
return await this.driverService.getTotalDrivers();
}
@Get('current')
@@ -47,8 +45,7 @@ export class DriverController {
return null;
}
const presenter = await this.driverService.getCurrentDriver(userId);
return presenter.viewModel;
return await this.driverService.getCurrentDriver(userId);
}
@Post('complete-onboarding')
@@ -59,8 +56,7 @@ export class DriverController {
@Req() req: AuthenticatedRequest,
): Promise<CompleteOnboardingOutputDTO> {
const userId = req.user!.userId;
const presenter = await this.driverService.completeOnboarding(userId, input);
return presenter.viewModel;
return await this.driverService.completeOnboarding(userId, input);
}
@Get(':driverId/races/:raceId/registration-status')
@@ -70,8 +66,7 @@ export class DriverController {
@Param('driverId') driverId: string,
@Param('raceId') raceId: string,
): Promise<DriverRegistrationStatusDTO> {
const presenter = await this.driverService.getDriverRegistrationStatus({ driverId, raceId });
return presenter.viewModel;
return await this.driverService.getDriverRegistrationStatus({ driverId, raceId });
}
@Get(':driverId')
@@ -79,8 +74,7 @@ export class DriverController {
@ApiResponse({ status: 200, description: 'Driver data', type: GetDriverOutputDTO })
@ApiResponse({ status: 404, description: 'Driver not found' })
async getDriver(@Param('driverId') driverId: string): Promise<GetDriverOutputDTO | null> {
const presenter = await this.driverService.getDriver(driverId);
return presenter.viewModel;
return await this.driverService.getDriver(driverId);
}
@Get(':driverId/profile')
@@ -88,8 +82,7 @@ export class DriverController {
@ApiResponse({ status: 200, description: 'Driver profile data', type: GetDriverProfileOutputDTO })
@ApiResponse({ status: 404, description: 'Driver not found' })
async getDriverProfile(@Param('driverId') driverId: string): Promise<GetDriverProfileOutputDTO> {
const presenter = await this.driverService.getDriverProfile(driverId);
return presenter.viewModel;
return await this.driverService.getDriverProfile(driverId);
}
@Put(':driverId/profile')
@@ -99,8 +92,7 @@ export class DriverController {
@Param('driverId') driverId: string,
@Body() body: { bio?: string; country?: string },
): Promise<GetDriverOutputDTO | null> {
const presenter = await this.driverService.updateDriverProfile(driverId, body.bio, body.country);
return presenter.viewModel;
return await this.driverService.updateDriverProfile(driverId, body.bio, body.country);
}
// Add other Driver endpoints here based on other presenters