Skip to content
Snippets Groups Projects
Commit ecf20265 authored by L4168's avatar L4168
Browse files

use controller to serve images

parent 1b8b320b
No related branches found
No related tags found
3 merge requests!59Development to master,!58Development to testing,!56Cluster update to Development
......@@ -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' });
}
}
......@@ -73,6 +73,8 @@ export class newGameDTO {
enddate: string;
@Length(0, 65)
image: string;
@Allow()
map?: JSON;
}
export class GameStateDTO {
......
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();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment