-
-
Notifications
You must be signed in to change notification settings - Fork 121
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 hono enhancer to cloudflare #923
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,14 +49,16 @@ export interface Config { | |
*/ | ||
middleware?: () => Promise<{ default: Middleware }>[]; | ||
/** | ||
* Enhander for Hono | ||
* Enhancer for Hono | ||
* Defaults to `undefined` | ||
*/ | ||
unstable_honoEnhancer?: | ||
| (<Hono>(createApp: (app: Hono) => Hono) => (app: Hono) => Hono) | ||
| undefined; | ||
unstable_honoEnhancer?: unstable_HonoEnhancer | undefined; | ||
} | ||
|
||
export type unstable_HonoEnhancer<Hono = never, MiddlewareHandler = never> = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to avoid exporting type from this file. If you need it in the plugin, simply define it there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that sounds good. |
||
createApp: (app: Hono) => Hono, | ||
) => Promise<(app: Hono, serveWaku: MiddlewareHandler) => Hono>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another idea would be: (createApp: (app: Hono) => Promise<Hono>) => (app: Hono) => Promise<Hono> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hm, on second thought, I wonder if promise is really necessary. Do you really need dynamic imports? Can you try top-level await? At this point, it's not convincing to change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I can try. It needs to import for the
Exposing the built Hono middleware (serveWaku) is useful if the user doesn't want Waku to be the default route. I agree that it doesn't look as clean. Maybe we should leave it out until someone has a more compelling use case? I am fine with transforming the build output for my personal use cases. I will make adjustments to this PR to remove the API changes. I will also try to fix the error it throws when deployed to Cloudflare. I tried using top-level await there but the same error occurred. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We expose
I would like it to be clean. 😄
Let me know if it doesn't work. There might be other workarounds. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
OK great. I will try that for the use case I am thinking of. |
||
|
||
export function defineConfig(config: Config) { | ||
return config; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.