-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b12bd78
commit f748da2
Showing
3 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,37 @@ | ||
import { Hono } from 'hono'; | ||
import { serve } from '@hono/node-server'; | ||
import { initNammatham, register } from 'nammatham'; | ||
import { logger } from 'hono/logger'; | ||
|
||
const app = new Hono().basePath('/api'); | ||
// DO NOT SET `basePath` for Hono App, Azure Functions will handle it | ||
const app = new Hono(); | ||
app.use(logger()); | ||
|
||
app.get('/SimpleHttpTrigger', c => { | ||
const userAgent = c.req.header('user-agent'); | ||
console.log(`user agent is: ${userAgent}`); | ||
const func = initNammatham(); | ||
|
||
const invocationId = c.req.header('x-azure-functions-invocationid'); | ||
console.log(`invocationid is: ${invocationId}`); | ||
app.all( | ||
...func.http({ | ||
route: '/SimpleHttpTrigger', | ||
}), | ||
c => { | ||
// Getting the function context | ||
const context = c.var.context; | ||
|
||
return c.text('Hello World from node.js worker'); | ||
}); | ||
context.log('JavaScript HTTP trigger function processed a request.'); | ||
context.log(`invocationid is: ${context.invocationId}`); | ||
context.log(`The third log message.`); | ||
|
||
return context.json({ | ||
hello: 'world', | ||
}); | ||
} | ||
); | ||
|
||
export default serve( | ||
register({ | ||
fetch: app.fetch, | ||
func, | ||
}) | ||
); | ||
|
||
const port = parseInt(process.env.FUNCTIONS_CUSTOMHANDLER_PORT || '4000'); | ||
console.log(`Start server on on http://localhost:${port}`); | ||
|
||
serve({ | ||
fetch: app.fetch, | ||
port, | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.