feat: implement azure-functions adapter
Author should do the followings, if applicable
- [ ] Add tests
- [ ] Run tests
- [ ]
yarn denoifyto 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~
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
export default httpTrigger;.
But otherwise, it may be useful to include the async function() part in the handler as well
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.
@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'.
@yusukebe
I misunderstood about a version that @azure/functions.
This PR will be making changes to support Azure Functions v4.
@ytnobody
Thanks! But, there's no need to hurry!
Hello awesome peeps, any update on this PR? Waiting for this feat for a long time. Would be a lifesaver!
Closing.
You can use https://github.com/Marplex/hono-azurefunc-adapter. Ref: https://github.com/honojs/website/issues/346