Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change addTool to multipart data #264

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

GeekaN2
Copy link
Member

@GeekaN2 GeekaN2 commented Jul 2, 2024

image

@GeekaN2 GeekaN2 force-pushed the feat/descriptions-and-covers branch from ece521b to 394023c Compare July 3, 2024 21:57
* Editor tool cover location
*/
export type EditorToolCoverFileLocation = {
isEditorToolCover: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe store toolId?

Comment on lines 95 to 96
// body: {
// $ref: 'AddEditorToolSchema',
// },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it, maybe add real validation?

Comment on lines +119 to +130
if (editorTool.cover) {
const coverBuffer = await editorTool.cover.toBuffer();

coverKey = await fileUploaderService.uploadFile({
data: coverBuffer,
name: createFileId(),
mimetype: editorTool.cover.mimetype,
}, {
isEditorToolCover: true,
}, {
userId,
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this logic into addTool()

Comment on lines 61 to 66
/**
* Update tool cover
* @param editorToolId
* @param cover
*/
public async updateToolCover(editorToolId: EditorTool['id'], cover: EditorTool['cover']): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty docs

@GeekaN2 GeekaN2 force-pushed the feat/descriptions-and-covers branch from a07998d to 60a0c18 Compare July 4, 2024 14:08
Copy link

github-actions bot commented Jul 4, 2024

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 84.17% (🎯 80%)
⬇️ -1.31%
7874 / 9354
🟢 Statements 84.17% (🎯 80%)
⬇️ -1.31%
7874 / 9354
🔴 Functions 74.68% (🎯 80%)
⬇️ -3.13%
236 / 316
🟢 Branches 84.88% (🎯 80%)
⬇️ -0.45%
382 / 450
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/domain/entities/editorTools.ts 0% 0% 0% 0% 1-62
src/domain/entities/file.ts 100% 100% 100% 100%
src/domain/service/editorTools.ts 85.33% 100% 50% 85.33% 28-29, 51-52, 61-65, 73-74
src/domain/service/fileUploader.service.ts 47.08% 100% 20% 47.08% 60-100, 109-110, 118-145, 152-173, 180-189, 196-197, 204-205, 212-222
src/presentation/http/http-api.ts 96.05% 90.32% 93.75% 96.05% 101-109, 120-121, 323-324, 347-348
src/presentation/http/router/editorTools.ts 70.62% 100% 100% 70.62% 71-75, 113-154
src/presentation/http/router/oauth.ts 59.77% 100% 100% 59.77% 48-82
src/presentation/http/router/dto/AddEditorTool.dto.ts 0% 0% 0% 0% 1-46
src/presentation/http/schema/AddEditorTool.ts 100% 100% 100% 100%
src/presentation/http/schema/EditorTool.ts 100% 100% 100% 100%
src/repository/editorTools.repository.ts 82.6% 100% 50% 82.6% 22-25, 49-50, 56-59, 67-68
src/repository/storage/postgres/orm/sequelize/editorTools.ts 83.41% 100% 50% 83.41% 142-161, 189-194, 200-201, 209-216
src/tests/utils/database-helpers.ts 98.17% 95.23% 91.66% 98.17% 194-199
Generated in workflow #790

src/domain/service/editorTools.ts Show resolved Hide resolved
src/domain/service/fileUploader.service.ts Show resolved Hide resolved
Comment on lines 143 to 144
title: String(editorTool.title?.value),
name: String(editorTool.name?.value),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsafe call

cover?: MultipartFile;

/**
* The user ID associated with the editor tool.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it the user who added a tool or who updated a tool last time?

Comment on lines +143 to +144
title: editorTool.title?.value ?? '',
name: editorTool.name?.value ?? '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to validate all required fields or add a schema

/**
* Tool cover
*/
EditorToolCover = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the numbers mean? Add description please

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all commented-out lines if it is not used

const { editorToolsService } = opts;
const { editorToolsService, fileUploaderService } = opts;

await fastify.register(fastifyMultipart, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the fastify.registed should be stored here
notes.api/src/presentation/http/http-api.ts

Comment on lines +17 to +22
NoteAttachment = 1,

/**
* Tool cover
*/
EditorToolCover = 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets store this as string enum for better readability

Comment on lines +84 to +85
// eslint-disable-next-line
const formData = new FormData();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spicify eslint rule that you are disabling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants