Skip to content

Conversation

@ogadra
Copy link
Contributor

@ogadra ogadra commented Nov 20, 2024

Related #24

Hello.
I added an example of #24 using Cloudflare Workers.

#24 (comment)

Screenshot

image

@ogadra ogadra changed the title feat: add example for cloudflare-workers [wip] feat: add example for cloudflare-workers Nov 20, 2024
}>()

app.use(async(c, next) => {
c.set('hono-context', 'hono-context')
Copy link
Contributor Author

@ogadra ogadra Nov 20, 2024

Choose a reason for hiding this comment

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

I need to change the variable's name and value.

Copy link
Owner

Choose a reason for hiding this comment

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

@ogadra ogadra changed the title [wip] feat: add example for cloudflare-workers [wip] feat: add an example for cloudflare-workers Nov 20, 2024
@ogadra ogadra marked this pull request as draft November 20, 2024 06:23
Comment on lines 4 to 11
const app = new Hono<{
Bindings: {
MY_VAR: string
}
},
Variables: {
'MY_VAR_IN_VARIABLES': string
},
}>()
Copy link
Contributor Author

@ogadra ogadra Nov 20, 2024

Choose a reason for hiding this comment

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

I think we can use Env imported from load-context.ts, but I didn't change it because I wasn't sure if I was allowed to.

Suggested change
const app = new Hono<{
Bindings: {
MY_VAR: string
}
},
Variables: {
'MY_VAR_IN_VARIABLES': string
},
}>()
+ import type { Env } from '../load-context'
+ const app = new Hono<Env>()

If I change it, I also need to update cloudflare-pages.

@ogadra ogadra marked this pull request as ready for review November 20, 2024 16:35
@ogadra ogadra requested a review from yusukebe November 20, 2024 16:35
@ogadra ogadra changed the title [wip] feat: add an example for cloudflare-workers feat: add an example for cloudflare-workers Nov 20, 2024
@yusukebe yusukebe deleted the branch yusukebe:feat/hono-context-in-get-load-context November 20, 2024 18:12
@yusukebe yusukebe closed this Nov 20, 2024
@yusukebe
Copy link
Owner

@ogadra

Oops. This PR was closed since #24 was merged. Can you create another PR?

@ogadra
Copy link
Contributor Author

ogadra commented Nov 20, 2024

@yusukebe I created #29 !

@yusukebe
Copy link
Owner

@ogadra Thanks!

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