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

Inversify Plugin #130

Closed
mildronize opened this issue Mar 26, 2024 · 0 comments · Fixed by #132
Closed

Inversify Plugin #130

mildronize opened this issue Mar 26, 2024 · 0 comments · Fixed by #132

Comments

@mildronize
Copy link
Collaborator

mildronize commented Mar 26, 2024

Poc in main.controller-inverify-plugin

https://github.com/thaitype/nammatham/blob/main.controller-inverify-plugin/examples/azure-functions-class-controller/src/main.ts

// Mock inversify plugin
declare function inverisfyPlugin(options: {
  container: Container;
  controllers: interfaces.ServiceIdentifier[];
}): (app: NammathamApp, handlerResolver: BaseHandlerResolver) => void;

// Manually register controllers
// const homeController = new HomeController(container.get(DataService));
// app.addFunctions(homeController.hello);

// Automatically register controllers
// This way will remove end-to-end type safety
app.register(inverisfyPlugin({ container, controllers: [HomeController] }));

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'));
});
@mildronize mildronize linked a pull request Apr 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant