refactor(server): immich file responses (#5641)

* refactor(server): immich file response

* chore: open api

* chore: tests

* chore: fix logger import

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Jason Rasmussen 2023-12-12 09:58:25 -05:00 committed by GitHub
parent af7c4ae090
commit cbca69841a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 186 additions and 154 deletions

View file

@ -3,7 +3,6 @@ import {
AssetResponseDto,
AuthDto,
BulkIdResponseDto,
ImmichReadStream,
MergePersonDto,
PeopleResponseDto,
PeopleUpdateDto,
@ -13,16 +12,12 @@ import {
PersonStatisticsResponseDto,
PersonUpdateDto,
} from '@app/domain';
import { Body, Controller, Get, Param, Post, Put, Query, StreamableFile } from '@nestjs/common';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated } from '../app.guard';
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Auth, Authenticated, FileResponse } from '../app.guard';
import { UseValidation } from '../app.utils';
import { UUIDParamDto } from './dto/uuid-param.dto';
function asStreamableFile({ stream, type, length }: ImmichReadStream) {
return new StreamableFile(stream, { type, length });
}
@ApiTags('Person')
@Controller('person')
@Authenticated()
@ -74,13 +69,9 @@ export class PersonController {
}
@Get(':id/thumbnail')
@ApiOkResponse({
content: {
'image/jpeg': { schema: { type: 'string', format: 'binary' } },
},
})
@FileResponse()
getPersonThumbnail(@Auth() auth: AuthDto, @Param() { id }: UUIDParamDto) {
return this.service.getThumbnail(auth, id).then(asStreamableFile);
return this.service.getThumbnail(auth, id);
}
@Get(':id/assets')