thaitype / nammatham

Azure Functions Framework
https://nammatham.thaitype.dev/
MIT License
67 stars 2 forks source link

Support both Node.js and Bun.js #123

Open mildronize opened 9 months ago

mildronize commented 9 months ago

Hono server will be greater option rather than express.js https://github.com/honojs/node-server

mildronize commented 9 months ago

propose use of hono

Way 1: Use hono plugin explicitly

import { initNammatham } from "@nammatham/core";
import { AzureFunctionsAdapter } from "@nammatham/azure-functions";
import { honoPlugin } from "@nammatham/hono"

const n = initNammatham.create(new AzureFunctionsAdapter());
const func = n.func;
const app = n.app;

const helloFunction = func
  .httpGet('hello')
  .handler(async ({ trigger, context }) => {
    return { body: `Hello, world!` };
  });

const dev = process.env.NODE_ENV === 'development';
app.register(honoPlugin({ dev }));
app.start();

Way 2: Use hono plugin implicitly

import { initNammatham } from "@nammatham/core";
import { AzureFunctionsAdapter } from "@nammatham/azure-functions";

const n = initNammatham.create(new AzureFunctionsAdapter());
const func = n.func;
const app = n.app;

const helloFunction = func
  .httpGet('hello')
  .handler(async ({ trigger, context }) => {
    return { body: `Hello, world!` };
  });

app.start();