Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer type from NammathamApp Endpoints #124

Open
mildronize opened this issue Jan 21, 2024 · 1 comment
Open

Infer type from NammathamApp Endpoints #124

mildronize opened this issue Jan 21, 2024 · 1 comment
Labels
azure-functions Related with azure-functions package need-poc

Comments

@mildronize
Copy link
Collaborator

mildronize commented Jan 21, 2024

Considering the new way to register functions

Do with:

Before

app.addFunctions(blob, hello);

After

Note: remove function name from httpGet first arg

export const myApp = app.addFunctions({ blob, hello });

// Register functions via object, may support type infer in the future
// type Endpoint = InferEndpoint<typeof myApp>

const userFunction = app.createFunctions({
  user: func.httpGet().handler(({ res }) => res.text('OK'));
});

app.mergeFunctions(userFunction);

Existing way

const userFunction = func.httpGet().handler( c => c.text('OK'));

app.addFunctions({
  user: userFunction
});

Single File

import { initNammatham, AzureFunctionsAdapter, expressPlugin } from "nammatham";

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

n.app.addFunctions({
  user: n.func.httpGet().handler( c => c.text('user'));
  post: n.func.httpGet().handler( c => c.text('post'));
})
.register(expressPlugin())
.start();

Standalone Mode (Like azure Function node.js library)

without using nammathamApp;

import { AzureFunctionsTrigger } from "nammatham";

new AzureFunctionsTrigger()
  .httpGet({ name: 'hello' })
  .handler( c => c.text('user'));
  .register();
@mildronize mildronize added v2-blocker Issue make V2 cannot be released need-poc azure-functions Related with azure-functions package and removed v2-blocker Issue make V2 cannot be released labels Jan 21, 2024
@mildronize mildronize removed the v2-blocker Issue make V2 cannot be released label Feb 17, 2024
@mildronize
Copy link
Collaborator Author

PoC defintion at branch: main.poc-inverisfyPlugin-type-safe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-functions Related with azure-functions package need-poc
Projects
None yet
Development

No branches or pull requests

1 participant