Skip to content

Conversation

@bitbeckers
Copy link
Collaborator

The goal of this PR is to provide a basic IPFS upload endpoint to self-reported evaluations on hypercerts data. Primarily, it should allow impact creators to provide updates on the data represented withing an hypercert, like evaluation reports or proof of work/attendance/etc..

  • Adds upload endpoint gates with multen middleware
  • Cleans up types used in libs
  • Increased test coverage threshold based on updated test suite

Adds an upload endpoint to our API. This has been implemented using
multer as a middleware for file validations and restrictions on file
size. Basic happy/unhappy flow tests pass.
Increases coverage threshold based on updated test suite
Updates the types used in lib/users to match updated API types
Generated updated Swagger
@bitbeckers bitbeckers added the enhancement New feature or request label Jan 3, 2025
@bitbeckers bitbeckers requested a review from pheuberger January 3, 2025 01:13
@bitbeckers bitbeckers self-assigned this Jan 3, 2025
@github-actions
Copy link

github-actions bot commented Jan 3, 2025

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 20.12% (🎯 17%) 1039 / 5164
🟢 Statements 20.12% (🎯 17%) 1039 / 5164
🟢 Functions 60.43% (🎯 54%) 55 / 91
🟢 Branches 63.86% (🎯 60%) 175 / 274
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/index.ts 0% 0% 0% 0% 1-61
src/controllers/AllowListController.ts 90% 90% 100% 90% 107-114
src/controllers/MetadataController.ts 41.37% 72.72% 50% 41.37% 61-73, 116-180, 214-228, 237-244, 261-308
src/controllers/UploadController.ts 97.01% 89.65% 100% 97.01% 153-154, 239, 243
src/lib/allowlists/isParsableToMerkleTree.ts 100% 100% 100% 100%
src/lib/allowlists/parseMerkleTree.ts 100% 100% 100% 100%
src/lib/uploads/errors.ts 100% 100% 100% 100%
src/lib/users/EOAUpsertStrategy.ts 0% 0% 0% 0% 1-74
src/lib/users/MultisigUpsertStrategy.ts 0% 0% 0% 0% 1-81
src/lib/users/UserUpsertStrategy.ts 0% 0% 0% 0% 1-23
src/lib/users/errors.ts 0% 100% 100% 0% 3-11
src/middleware/upload.ts 84.09% 90% 50% 84.09% 55-61
src/utils/validateRemoteAllowList.ts 5.4% 100% 0% 5.4% 6-43
Generated in workflow #13 for commit 25c613c by the Vitest Coverage Report Action

Add validations on file type and size
To gradually clean up the repo, we agreed on restructuring helpers from
utils to more cleanly scoped libs. Additionally, added some tests
Copy link
Member

@pheuberger pheuberger left a comment

Choose a reason for hiding this comment

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

I have some preliminary feedback on the controller. I haven't reviewed the tests yet and the later commits, but wanted to share already.

@tnkshuuhei
Copy link
Member

@bitbeckers
I gotMulterError: File too large error when I tried to upload pdf(9.7MB).
This pdf was a product deck that has 20 pages, imagine creator try to upload large pdfs like impact report....

small pdfs(<1MB) were fine at all.

Updates the UploadController to use custom errors. The custom errors are
defined in a uploads lib directory and handles all cases found in the
controller.
Updates the UploadController typedoc example to document different
upload tools and the expected responses
Adds typeguards and updates the parsing of failed and successful file
uploads for readability
Updates the test cases to test on the expanded upload result types.
Additionally typedoc documentation was updated to document the error and
the controller more accurately.
@bitbeckers
Copy link
Collaborator Author

@bitbeckers I gotMulterError: File too large error when I tried to upload pdf(9.7MB). This pdf was a product deck that has 20 pages, imagine creator try to upload large pdfs like impact report....

small pdfs(<1MB) were fine at all.

Issues created #205 (comment)

Copy link
Member

@pheuberger pheuberger left a comment

Choose a reason for hiding this comment

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

Nice, looks very clean. All my comments are non-blocking, so feel free to merge any time!

@bitbeckers
Copy link
Collaborator Author

Sorry @pheuberger but I need to resolve all non-blocking comments because they block the PR

@bitbeckers bitbeckers merged commit 59dc9f2 into develop Jan 20, 2025
1 check passed
@bitbeckers bitbeckers deleted the feat/file_upload_endpoint branch January 21, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants