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(factory): Allow HonoOptions<E> with factory #3786

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

Conversation

miyaji255
Copy link

When using factory, options such as strict: false cannot be specified. This Pull Request allows you to specify options when calling createFactory and createApp.

const factory = createFactory({ defaultOptions: { strict: false } });
const app = factory.createApp({ options: { strict: true } }); // Override defaultOptions

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.71%. Comparing base (1e62912) to head (24337a9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3786      +/-   ##
==========================================
- Coverage   91.71%   91.71%   -0.01%     
==========================================
  Files         160      160              
  Lines       10181    10198      +17     
  Branches     2896     2935      +39     
==========================================
+ Hits         9338     9353      +15     
- Misses        842      844       +2     
  Partials        1        1              

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


constructor(init?: { initApp?: InitApp<E> }) {
constructor(init?: { initApp?: InitApp<E>; defaultOptions?: HonoOptions<E> }) {
Copy link
Member

Choose a reason for hiding this comment

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

Factory does not provide only createApp() but it provides createMiddleware() and createHandlers(). So the name defaultOptions may introduce confusion because the user may understand the option is not for createApp(). So I think it should have a different name, such as defaultAppOptions.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for pointing that out. I completely overlooked the fact that it's not just about the app.

@yusukebe
Copy link
Member

yusukebe commented Jan 1, 2025

Hi @miyaji255

Thank you for the PR. I think this is a good feature. I've left the comment.

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.

2 participants