From 2d7778f7d1fa2f34e8baeaeb75f235c25767c6ca Mon Sep 17 00:00:00 2001 From: magdo Date: Mon, 20 Oct 2025 19:17:43 +0200 Subject: [PATCH] test removed --- SerpentRace_Backend/src/Api/routers/tests.ts | 66 -------------------- 1 file changed, 66 deletions(-) delete mode 100644 SerpentRace_Backend/src/Api/routers/tests.ts diff --git a/SerpentRace_Backend/src/Api/routers/tests.ts b/SerpentRace_Backend/src/Api/routers/tests.ts deleted file mode 100644 index 33b880f3..00000000 --- a/SerpentRace_Backend/src/Api/routers/tests.ts +++ /dev/null @@ -1,66 +0,0 @@ -import e, { Router } from 'express'; -import { container, DIContainer } from '../../Application/Services/DIContainer'; -import { ErrorResponseService } from '../../Application/Services/ErrorResponseService'; -import { logRequest, logError, logAuth, logWarning, logOther } from '../../Application/Services/Logger'; -import { GenerateBoardCommand } from '../../Application/Game/commands/GenerateBoardCommand'; - -const router = Router(); - -//function to test the search service -async function triggerAsyncBoardGeneration(gameId: string): Promise { - try { - // Calculate default field counts based on game configuration - // For now, use reasonable defaults - this should be configurable by host in the future - const maxSpecialFieldsPercentage = parseInt(process.env.MAX_SPECIAL_FIELDS_PERCENTAGE || '67'); - const maxSpecialFields = Math.floor((100 * maxSpecialFieldsPercentage) / 100); - - // Default distribution: 60% positive, 25% negative, 15% luck - const positiveFieldCount = Math.floor(maxSpecialFields * 0.6); - const negativeFieldCount = Math.floor(maxSpecialFields * 0.25); - const luckFieldCount = Math.floor(maxSpecialFields * 0.15); - - const command: GenerateBoardCommand = { - gameId, - positiveFieldCount, - negativeFieldCount, - luckFieldCount - }; - - logOther(`Triggering async board generation for game ${gameId}`, { - positiveFieldCount, - negativeFieldCount, - luckFieldCount, - totalSpecialFields: positiveFieldCount + negativeFieldCount + luckFieldCount - }); - - // Execute board generation in background - await DIContainer.getInstance().generateBoardCommandHandler.execute(command); - return true; - - } catch (error) { - logError(`Async board generation failed for game ${gameId}`, error as Error); - // Don't propagate error - board generation failure shouldn't affect game creation - return false; - } - } - - -// Game board generation endpoint -router.post('/gameBoardGeneration', async (req, res) => { - try { - logRequest('Game board generation endpoint accessed', req, res); - - const result = await triggerAsyncBoardGeneration("######-#####-#####-######"); - - if (result) { - logOther('Game board generation triggered successfully', result); - return res.json({ message: 'Game board generation triggered successfully' }); - } else { - throw new Error('Game board generation failed to trigger'); - } - } catch (error : any) { - logError('Error in game board generation endpoint', error); - return ErrorResponseService.sendInternalServerError(res); - } -}); -export default router; \ No newline at end of file