Skip to content

Commit

Permalink
OV-439: + imageService
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiy4 committed Sep 26, 2024
1 parent 2b03b47 commit 3cb6c59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions backend/src/bundles/templates/templates.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HTTPCode, HttpError } from '~/common/http/http.js';
import { type ImageService } from '~/common/services/image/image.service.js';
import { type Service } from '~/common/types/types.js';

import { type UpdateVideoRequestDto } from '../videos/types/types.js';
Expand All @@ -14,9 +15,14 @@ import {

class TemplateService implements Service {
private templateRepository: TemplateRepository;
private imageService: ImageService;

public constructor(templateRepository: TemplateRepository) {
public constructor(
templateRepository: TemplateRepository,
imageService: ImageService,
) {
this.templateRepository = templateRepository;
this.imageService = imageService;
}

public async findById(id: string): Promise<TemplateEntity | null> {
Expand Down Expand Up @@ -54,7 +60,8 @@ class TemplateService implements Service {
const { composition, name, userId } = payload;

// TODO: CREATE PREVIEW
const compositionPreviewUrl = composition.scenes[0]?.avatar?.url ?? '';
const compositionPreviewUrl =
await this.imageService.generatePreview(composition);

const user = await this.templateRepository.create(
TemplateEntity.initializeNew({
Expand Down
3 changes: 2 additions & 1 deletion backend/src/bundles/templates/templates.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { logger } from '~/common/logger/logger.js';
import { imageService } from '~/common/services/services.js';

import { TemplateController } from './templates.controller.js';
import { TemplateModel } from './templates.model.js';
import { TemplateRepository } from './templates.repository.js';
import { TemplateService } from './templates.service.js';

const templateRepository = new TemplateRepository(TemplateModel);
const templateService = new TemplateService(templateRepository);
const templateService = new TemplateService(templateRepository, imageService);
const templateController = new TemplateController(logger, templateService);

export { templateController };

0 comments on commit 3cb6c59

Please sign in to comment.