Skip to content

Commit 1cfd107

Browse files
committed
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-2024-outreachvids into task/OV-307-show-video-thumbnails
2 parents 274decf + c8b79fb commit 1cfd107

File tree

169 files changed

+13278
-5948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+13278
-5948
lines changed

backend/.env.example

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ AWS_SECRET_ACCESS_KEY=see-in-slack
2626
AWS_S3_REGION=eu-north-1
2727
AWS_S3_BUCKET_NAME=bsa-2024-outreachvids
2828
AWS_CLOUDFRONT_DOMAIN_ID=d2tm5q3cg1nlwf
29+
AWS_CLOUDFRONT_DOMAIN_ID_FOR_RENDERED_VIDEO=SOME_SECRET_KEY
2930

3031
#
3132
# OPEN AI
@@ -48,3 +49,10 @@ ORIGIN=http://localhost:3000
4849
AZURE_SUBSCRIPTION_KEY=see-in-slack
4950
AZURE_SERVICE_REGION=see-in-slack
5051
AZURE_SERVICE_ENDPOINT=see-in-slack
52+
53+
#
54+
# REMOTION
55+
#
56+
REMOTION_LAMBDA_FUNCTION_NAME=SOME_SECRET_KEY
57+
REMOTION_SERVE_URL=SOME_SECRET_KEY
58+
REMOTION_BUCKET_NAME=SOME_SECRET_KEY

backend/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"@fastify/static": "7.0.4",
3939
"@fastify/swagger": "8.15.0",
4040
"@fastify/swagger-ui": "4.0.1",
41+
"@remotion/lambda": "4.0.201",
4142
"bcrypt": "5.1.1",
4243
"convict": "6.2.4",
4344
"dotenv": "16.4.5",

backend/src/bundles/auth/auth.controller.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
BaseController,
1111
} from '~/common/controller/controller.js';
1212
import { ApiPath } from '~/common/enums/enums.js';
13-
import { HttpCode, HTTPMethod } from '~/common/http/http.js';
13+
import { HTTPCode, HTTPMethod } from '~/common/http/http.js';
1414
import { type Logger } from '~/common/logger/logger.js';
1515

1616
import { type AuthService } from './auth.service.js';
@@ -95,7 +95,7 @@ class AuthController extends BaseController {
9595
): Promise<ApiHandlerResponse> {
9696
return {
9797
payload: await this.authService.signIn(options.body),
98-
status: HttpCode.OK,
98+
status: HTTPCode.OK,
9999
};
100100
}
101101

@@ -144,7 +144,7 @@ class AuthController extends BaseController {
144144
}>,
145145
): Promise<ApiHandlerResponse> {
146146
return {
147-
status: HttpCode.CREATED,
147+
status: HTTPCode.CREATED,
148148
payload: await this.authService.signUp(options.body),
149149
};
150150
}

backend/src/bundles/auth/auth.service.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
type UserSignInRequestDto,
88
type UserSignInResponseDto,
99
} from '~/bundles/users/users.js';
10-
import { HttpCode, HttpError } from '~/common/http/http.js';
10+
import { HTTPCode, HttpError } from '~/common/http/http.js';
1111
import { cryptService, tokenService } from '~/common/services/services.js';
1212

1313
import { UserValidationMessage } from './enums/enums.js';
@@ -28,21 +28,21 @@ class AuthService {
2828
if (!user) {
2929
throw new HttpError({
3030
message: UserValidationMessage.WRONG_CREDENTIALS,
31-
status: HttpCode.BAD_REQUEST,
31+
status: HTTPCode.BAD_REQUEST,
3232
});
3333
}
3434

3535
const { passwordHash } = user.toNewObject();
3636

37-
const isPwdCorrect = cryptService.compareSyncPassword(
37+
const isPasswordCorrect = cryptService.compareSyncPassword(
3838
password,
3939
passwordHash,
4040
);
4141

42-
if (!isPwdCorrect) {
42+
if (!isPasswordCorrect) {
4343
throw new HttpError({
4444
message: UserValidationMessage.WRONG_CREDENTIALS,
45-
status: HttpCode.BAD_REQUEST,
45+
status: HTTPCode.BAD_REQUEST,
4646
});
4747
}
4848

@@ -60,7 +60,7 @@ class AuthService {
6060
if (emailExists) {
6161
throw new HttpError({
6262
message: UserValidationMessage.EMAIL_ALREADY_EXISTS,
63-
status: HttpCode.BAD_REQUEST,
63+
status: HTTPCode.BAD_REQUEST,
6464
});
6565
}
6666
const user = await this.userService.create(userRequestDto);

backend/src/bundles/avatar-videos/avatar-videos.controller.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type ApiHandlerResponse,
66
} from '~/common/controller/controller.js';
77
import { BaseController } from '~/common/controller/controller.js';
8-
import { HttpCode, HTTPMethod } from '~/common/http/http.js';
8+
import { HTTPCode, HTTPMethod } from '~/common/http/http.js';
99
import { type Logger } from '~/common/logger/logger.js';
1010

1111
import { type AvatarVideoService } from './avatar-videos.service.js';
@@ -77,24 +77,28 @@ class AvatarVideoController extends BaseController {
7777
}>,
7878
): Promise<ApiHandlerResponse> {
7979
const userId = (options.user as UserGetCurrentResponseDto).id;
80-
const videoRecord = await this.avatarVideoService.createVideo({
81-
...options.body,
82-
userId,
83-
});
80+
const { composition, name, videoId } = options.body;
8481

85-
const avatarsConfigs = this.avatarVideoService.getAvatarsConfigs(
86-
options.body.composition,
87-
);
82+
const videoPayload = {
83+
name,
84+
composition,
85+
};
86+
87+
const videoRecord = await (videoId
88+
? this.avatarVideoService.updateVideo({ ...videoPayload, videoId })
89+
: this.avatarVideoService.createVideo({ ...videoPayload, userId }));
90+
91+
const avatarsConfigs =
92+
this.avatarVideoService.getAvatarsConfigs(composition);
8893

8994
await this.avatarVideoService.submitAvatarsConfigs(
9095
avatarsConfigs,
91-
userId,
9296
videoRecord.id,
9397
);
9498

9599
return {
96100
payload: { status: ResponseStatus.SUBMITTED },
97-
status: HttpCode.CREATED,
101+
status: HTTPCode.CREATED,
98102
};
99103
}
100104
}

0 commit comments

Comments
 (0)