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: add support for image helpers in nitro endpoints #1473

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

Conversation

Afshar07
Copy link

@Afshar07 Afshar07 commented Sep 5, 2024

Implement image helper utilities usage in nitro endpoints, by adding image options and nitro compatible utils in server directory.
But to be honest, it's my first contribution and i might (probably am) mess with a wrong config, so, it will be so kind for anyone to point out if i have done anything wrong!

🔗 Linked issue

resolves #1447

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Add an utility on server folder and auto import it into nitro, and also write image options into a virtual path in nitro.
Set a boolean to check if the utility is used in nitro environment, if it is, ignore prerendering static images.

// Prerender static images
if (import.meta.server && import.meta.prerender) {
if (import.meta.server && import.meta.prerender && !isCalledInNitro) {
Copy link
Member

@danielroe danielroe Sep 10, 2024

Choose a reason for hiding this comment

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

why do we not want to hint to prerender static images if called from a server endpoint?

maybe instead we use getEvent and prerender them if it's available?

Copy link
Author

@Afshar07 Afshar07 Sep 13, 2024

Choose a reason for hiding this comment

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

Thanks for the hint, i have tried the generate command and i see that beside this, i have a lot of unhandled situations!
But my main problem is i do not have access to image-options virtual file in nitro when generating, i need to handle that.
I investigate the source code more precisely, review my code and come back with a solution ASAP.
Is there anything specific i need to know? like about writing tests or anything else?
Thanks for your time.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 50.00000% with 15 lines in your changes missing coverage. Please review.

Project coverage is 63.22%. Comparing base (f087d01) to head (b5a9ebf).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/runtime/server/utils/image.ts 0.00% 12 Missing and 1 partial ⚠️
src/module.ts 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1473      +/-   ##
==========================================
- Coverage   63.37%   63.22%   -0.16%     
==========================================
  Files          79       80       +1     
  Lines        3607     3630      +23     
  Branches      407      411       +4     
==========================================
+ Hits         2286     2295       +9     
- Misses       1292     1304      +12     
- Partials       29       31       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

add support for image helpers in nitro endpoints
3 participants