Skip to content

Commit 57b54c2

Browse files
committed
feat: change function method for video function to be more generic
1 parent 5821141 commit 57b54c2

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

apps/backend/src/api/routes/media.controller.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { SubscriptionService } from '@gitroom/nestjs-libraries/database/prisma/s
2424
import { UploadFactory } from '@gitroom/nestjs-libraries/upload/upload.factory';
2525
import { SaveMediaInformationDto } from '@gitroom/nestjs-libraries/dtos/media/save.media.information.dto';
2626
import { VideoDto } from '@gitroom/nestjs-libraries/dtos/videos/video.dto';
27+
import { VideoFunctionDto } from '@gitroom/nestjs-libraries/dtos/videos/video.function.dto';
2728

2829
@ApiTags('Media')
2930
@Controller('/media')
@@ -181,13 +182,11 @@ export class MediaController {
181182
return this._mediaService.getVideoOptions();
182183
}
183184

184-
@Post('/video/:identifier/:function')
185+
@Post('/video/function')
185186
videoFunction(
186-
@Param('identifier') identifier: string,
187-
@Param('function') functionName: string,
188-
@Body('params') body: any
187+
@Body() body: VideoFunctionDto
189188
) {
190-
return this._mediaService.videoFunction(identifier, functionName, body);
189+
return this._mediaService.videoFunction(body.identifier, body.functionName, body.params);
191190
}
192191

193192
@Get('/generate-video/:type/allowed')

apps/frontend/src/components/videos/video.render.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export const useVideoFunction = () => {
1616
return useCallback(
1717
async (funcName: string, params: any) => {
1818
return (
19-
await fetch(`/media/video/${identifier}/${funcName}`, {
19+
await fetch(`/media/video/function`, {
2020
method: 'POST',
21-
body: JSON.stringify({ params }),
21+
body: JSON.stringify({ identifier, functionName: funcName, params }),
2222
headers: {
2323
'Content-Type': 'application/json',
2424
},
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { IsString } from 'class-validator';
2+
3+
export class VideoFunctionDto {
4+
@IsString()
5+
identifier: string;
6+
7+
@IsString()
8+
functionName: string;
9+
10+
params: any;
11+
}

0 commit comments

Comments
 (0)