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: implement azure-functions adapter #1797

Closed

Conversation

ytnobody
Copy link

@ytnobody ytnobody commented Dec 9, 2023

Author should do the followings, if applicable

  • Add tests
  • Run tests
  • yarn denoify to generate files for Deno

usage:

import { Hono } from 'hono'
import { logger } from 'hono/logger'
import { AzureFunction, Context, HttpRequest, handle } from 'hono/adapter/azure-functions'

const app = new Hono()
app.use('*', logger())

app.all('/api/:funcname', async (c) => {
  const message = 'Hello, Azure Functions and Hono!'
  const query = c.req.queries()
  const json_body = c.req.method === "POST" ? await c.req.json() : {};
  const headers = c.req.header()
  return c.json({ message, query, json_body, headers })
})

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
  context.log('HTTP trigger function processed a request.')
  context = await handle(app)({ context, req })
}

export default httpTrigger

requirement

  • @azure/functions ^3.0.0

@watany-dev
Copy link
Contributor

I am a developer maintaining an AWS lambda handler

If AzureFunctions user values customizability, this interface looks good.

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise {
context.log('HTTP trigger function processed a request.');
context = await handle(app)({ context, req });
};

export default httpTrigger;.

But otherwise, it may be useful to include the async function() part in the handler as well

@ytnobody ytnobody marked this pull request as ready for review December 12, 2023 12:48
@yusukebe
Copy link
Member

Hi @ytnobody,

Thank you for the PR. Supporting Azure Functions is a great feature for Hono. We also have issue #1747 .

I will try it out and assess how it feels to use. So, please wait for a moment.

@watany-dev, I might ask you to review this as well.

@yusukebe
Copy link
Member

@ytnobody

I believe the feature in this PR is for 'version 3', but 'version 4' is now available:

https://learn.microsoft.com/en-us/azure/azure-functions/functions-node-upgrade-v4?tabs=v4

Since 'version 3' might no longer be supported, we should update it for 'version 4'.

@ytnobody
Copy link
Author

@yusukebe

I misunderstood about a version that @azure/functions.

This PR will be making changes to support Azure Functions v4.

@ytnobody ytnobody marked this pull request as draft December 13, 2023 03:44
@yusukebe
Copy link
Member

@ytnobody

Thanks! But, there's no need to hurry!

@mhsrio
Copy link

mhsrio commented Mar 25, 2024

Hello awesome peeps, any update on this PR? Waiting for this feat for a long time. Would be a lifesaver!

@yusukebe
Copy link
Member

yusukebe commented May 9, 2024

Closing.

You can use https://github.com/Marplex/hono-azurefunc-adapter. Ref: honojs/website#346

@yusukebe yusukebe closed this May 9, 2024
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.

None yet

4 participants