diff --git a/src/game/game.controller.ts b/src/game/game.controller.ts index 238f54c56944bf52700eda70f31d00f5820a4b9c..b79699c3e50130bc9a9537257c0130182ef278ea 100644 --- a/src/game/game.controller.ts +++ b/src/game/game.controller.ts @@ -11,6 +11,7 @@ import { ClassSerializerInterceptor, Delete, UploadedFile, + Res, } from '@nestjs/common'; import { FileInterceptor } from '@nestjs/platform-express'; import { diskStorage } from 'multer'; @@ -126,4 +127,9 @@ export class GameController { uploadImage(@UploadedFile() image) { return image; } + + @Get('images/:img') + returnImage(@Param('img') image, @Res() res) { + return res.sendFile(image, { root: 'images' }); + } } diff --git a/src/game/game.dto.ts b/src/game/game.dto.ts index 081a9aeb348d913164c625f587af0fd01281401d..e6d99869c101eedc77d7050275c2de4d09b9540f 100644 --- a/src/game/game.dto.ts +++ b/src/game/game.dto.ts @@ -73,6 +73,8 @@ export class newGameDTO { enddate: string; @Length(0, 65) image: string; + @Allow() + map?: JSON; } export class GameStateDTO { diff --git a/src/main.ts b/src/main.ts index e0a6253c9fd220b51ad454ebdd3c2012db3201e8..ebd53e5906d44738a4775716b7165108fae426ca 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,4 @@ import { NestFactory } from '@nestjs/core'; -import { NestExpressApplication } from '@nestjs/platform-express'; -import { join } from 'path'; import { AppModule } from './app.module'; @@ -9,10 +7,9 @@ import { AppModule } from './app.module'; */ async function bootstrap() { - const app = await NestFactory.create<NestExpressApplication>(AppModule); + const app = await NestFactory.create(AppModule); // Cors is needed for application/json POST app.enableCors(); - app.useStaticAssets(join(__dirname, '..', 'images')); await app.listen(5000); } bootstrap();