streamer service: split to separate files

This commit is contained in:
Jurgis Sakalauskas
2022-12-15 11:00:15 +02:00
parent 72c5684da9
commit 2fb78b61c4
14 changed files with 204 additions and 128 deletions
+2 -2
View File
@@ -29,8 +29,8 @@ export class AllFilesController {
@Param('fileId') fileId: string,
@Req() request: Request,
@Res() response: Response,
) {
this.allFilesService.play(fileId, request, response);
): Promise<void> {
return this.allFilesService.play(fileId, request, response);
}
@Get(':titleId/:seasonId?')
+6 -7
View File
@@ -135,17 +135,16 @@ export class AllFilesService {
response: Response,
): Promise<void> {
const id = parseInt(fileId);
if (isNaN(id)) {
throw new NotFoundException(`id #${fileId} not correct`);
}
const entity = await this.fileRepository.findOne({ where: { id: id } });
if (entity === null) {
response
.status(404)
.send('entity not found id: ' + fileId)
.end();
return;
throw new NotFoundException(`id #${fileId} not found`);
}
this.streamerFacade.streamFile(request, response, entity.path);
return this.streamerFacade.streamFile(request, response, entity.path);
}
}