Skip to content

Commit

Permalink
refactor(nammatham): azure function metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mildronize committed May 16, 2024
1 parent 263ecee commit 96ad895
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/main/src/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createMiddleware } from 'hono/factory';

import type { HttpTriggerOptions, InvocationContext, NammathamTrigger } from './types';

import { Nammatham } from '../dist/main';
import { Nammatham } from './main';

type HonoEnv = {
Variables: {
Expand Down
34 changes: 18 additions & 16 deletions packages/main/src/nammatham.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,24 @@ export class Nammatham implements NammathamTrigger {
}
this.functions.push({
name: camelCase(options.name ?? options.route),
bindings: [
{
type: 'httpTrigger',
// TODO: Add Support default value by configuring in options
authLevel: options.authLevel ?? 'function',
route: options.route,
direction: 'in',
name: 'req',
methods: options.methods ?? ['GET', 'POST', 'PUT', 'DELETE'],
},
{
type: 'http',
direction: 'out',
name: 'res',
},
],
metadata: {
bindings: [
{
type: 'httpTrigger',
// TODO: Add Support default value by configuring in options
authLevel: options.authLevel ?? 'function',
route: options.route,
direction: 'in',
name: 'req',
methods: options.methods ?? ['GET', 'POST', 'PUT', 'DELETE'],
},
{
type: 'http',
direction: 'out',
name: 'res',
},
],
},
});
return this;
}
Expand Down
7 changes: 5 additions & 2 deletions packages/main/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ export interface AzureFunctionBindings extends Record<string, unknown> {
name: string;
}

export interface AzureFunctionMetadata extends Record<string, unknown> {
bindings: AzureFunctionBindings[];
}

export interface NammathamFunction {
name: string;
metadata?: Record<string, unknown>;
bindings: AzureFunctionBindings[];
metadata?: AzureFunctionMetadata;
}

export type HttpMethods = 'GET' | 'POST' | 'PUT' | 'DELETE';
Expand Down

0 comments on commit 96ad895

Please sign in to comment.