Skip to content

Conversation

@rafael-gal
Copy link

Backend
Implemented PDF viewer API
Implemented Docs viewer API

Frontend
Created file reader

Backend
Implemented PDF viewer API
Implemented Docs viewer API

Frontend
Created file reader
@flip-in flip-in requested a review from Copilot July 31, 2025 20:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a file viewer feature that allows users to view PDF and DOCX files. The backend provides new API endpoints for file content retrieval and viewing, while the frontend adds components to display these files appropriately.

  • Added backend endpoints for viewing PDF files and converting DOCX files to HTML
  • Enhanced frontend with file type detection and rendering components
  • Updated file interface to include filename property

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
frontend/src/app/page.tsx Added file viewer functionality with PDF and DOCX rendering components
backend/server.js Implemented new API endpoints for file content retrieval and PDF viewing
Comments suppressed due to low confidence (4)

frontend/src/app/page.tsx:73

  • Variable name 'file_split' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileSplit'.
    const file_split = file.filename.split('.')

frontend/src/app/page.tsx:74

  • Variable name 'file_type' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileType'.
    const file_type = file_split.slice(-1)[0]

backend/server.js:59

  • Variable name 'file_type' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileType'.
  const file_type = path.extname(file.filename)

backend/server.js:80

  • Variable name 'file_type' uses snake_case which is inconsistent with the camelCase convention used throughout the codebase. Consider renaming to 'fileType'.
  const file_type = path.extname(file.filename)

interface File {
id: string;
name: string;
filename: string
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Missing semicolon at the end of the filename property declaration. This is inconsistent with the other interface properties.

Suggested change
filename: string
filename: string;

Copilot uses AI. Check for mistakes.

})
{
return (
<div dangerouslySetInnerHTML={{__html: html}}></div>
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Using dangerouslySetInnerHTML with unsanitized HTML content from the server creates a potential XSS vulnerability. Consider sanitizing the HTML content before rendering.

Copilot uses AI. Check for mistakes.

})
{
return (
<iframe src={link} width={750} height={1000} />
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The iframe is missing important security attributes. Consider adding 'sandbox' and 'title' attributes for better security and accessibility.

Suggested change
<iframe src={link} width={750} height={1000} />
<iframe src={link} width={750} height={1000} sandbox="allow-scripts allow-same-origin" title="PDF Viewer" />

Copilot uses AI. Check for mistakes.

};

useEffect(() => {
setFileLoading(true)
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Missing semicolon at the end of the statement. This is inconsistent with the coding style used elsewhere in the file.

Suggested change
setFileLoading(true)
setFileLoading(true);

Copilot uses AI. Check for mistakes.

Comment on lines +64 to +66
console.error("file not found!")
setFileLoading(false)
return
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Missing semicolon at the end of the statement. This is inconsistent with the coding style used elsewhere in the file.

Suggested change
console.error("file not found!")
setFileLoading(false)
return
console.error("file not found!");
setFileLoading(false);
return;

Copilot uses AI. Check for mistakes.

}
const file_type = path.extname(file.filename)
if ( file_type !== '.pdf' ) {
return res.status(422).json({ message: "Preview not supported" });
Copy link

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

Inconsistent error response format. This endpoint uses 'message' property while other error responses use 'error' property. Should be consistent across the API.

Suggested change
return res.status(422).json({ message: "Preview not supported" });
return res.status(422).json({ error: "Preview not supported" });

Copilot uses AI. Check for mistakes.

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.

1 participant