Skip to content

Commit

Permalink
refactor(nammatham): rename class
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize committed May 15, 2024
1 parent f748da2 commit 1d83e1e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
4 changes: 2 additions & 2 deletions examples/with-bun/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Hono } from 'hono';
import { logger } from 'hono/logger';
import { initNammatham, register } from 'nammatham';
import { HonoAzureMiddleware, register } from 'nammatham';

// DO NOT SET `basePath` for Hono App, Azure Functions will handle it
const app = new Hono();
app.use(logger());

const func = initNammatham();
const func = new HonoAzureMiddleware();

app.all(
...func.http({
Expand Down
4 changes: 2 additions & 2 deletions examples/with-node/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Hono } from 'hono';
import { serve } from '@hono/node-server';
import { initNammatham, register } from 'nammatham';
import { HonoAzureMiddleware, register } from 'nammatham';
import { logger } from 'hono/logger';

// DO NOT SET `basePath` for Hono App, Azure Functions will handle it
const app = new Hono();
app.use(logger());

const func = initNammatham();
const func = new HonoAzureMiddleware();

app.all(
...func.http({
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/bun.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// import type { Serve } from 'bun';

import type { FunctionTrigger } from './lib';
import type { HonoAzureMiddleware } from './hono';

export type FetchCallback = (request: Request, env: Record<string, unknown>) => Promise<Response> | Response;

export interface NammathamRegisterOptions {
fetch: FetchCallback;
func: FunctionTrigger;
func: HonoAzureMiddleware;
}

export function register(option: NammathamRegisterOptions) {
Expand Down
6 changes: 1 addition & 5 deletions packages/main/src/lib.ts → packages/main/src/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ type HonoEnv = {
};
};

export function initNammatham(options?: any){
return new FunctionTrigger();
}

export class FunctionTrigger {
export class HonoAzureMiddleware {
http<const TRoute extends string>(options: HttpTriggerOptions<TRoute>): [TRoute, MiddlewareHandler<HonoEnv>] {
const middleware = createMiddleware<HonoEnv>(async (c, next) => {
const logMessages: string[] = [];
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './lib';
export * from './hono';
export * from './types';
export * from './bun';

0 comments on commit 1d83e1e

Please sign in to comment.