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

Add hooks api to framework package #7

Closed
ejizba opened this issue Aug 24, 2022 · 2 comments · Fixed by #181
Closed

Add hooks api to framework package #7

ejizba opened this issue Aug 24, 2022 · 2 comments · Fixed by #181

Comments

@ejizba
Copy link
Contributor

ejizba commented Aug 24, 2022

At the moment hooks are only exposed in the core api. However, we want the new programming model packages to wrap the core api and expose a "nicer" version of the hooks api (better intellisense, maybe better naming, full docs, etc.)

@ejizba ejizba added v4 🚀 We no longer use this label since v4 is now the default model. P1 feature labels Aug 24, 2022
@ejizba ejizba changed the title Add hooks api to new programming model Add hooks api to v4 Aug 24, 2022
@hossam-nasr hossam-nasr self-assigned this Aug 25, 2022
@ejizba ejizba modified the milestones: September 2022, October 2022 Sep 6, 2022
@ejizba ejizba changed the title Add hooks api to v4 Add hooks api to framework package Sep 28, 2022
@ejizba ejizba modified the milestones: October 2022, November 2022 Oct 31, 2022
@ejizba ejizba modified the milestones: November 2022, January 2023 Nov 30, 2022
@ejizba ejizba modified the milestones: January 2023, February 2023 Jan 30, 2023
@aaronpowell
Copy link
Contributor

This builds on some of the ideas proposed in Azure/azure-functions-nodejs-worker#664

Here's an idea I have for how we could do middleware:

import { app } from "@azure/functions";

app.get("home", () => ({ body: "Hello World" });

app.middleware({
  hookName: "preInvocation",
  hook: (context) => {
    //do stuff
  }
});

app.preInvocation(context => {
  //do stuff
});

app.middleware({
  hookName: "preInvocation",
  filter: "httpTrigger"
  hook: () => {}
});

app.middleware({
  hookName: "preInvocation",
  filter: (context) => context.trigger.url.contains("foo"),
  hook: () => {}
});

There's probably a bunch of additional permutations that we could support to make it more akin to the kind of middleware like you would come across in web frameworks, but also support the scenarios of having different trigger types within your application.

@aaronpowell
Copy link
Contributor

Also, once Azure/azure-functions-nodejs-worker#665 is implemented, we can make the types available for the context of a hook callback richer so that it's possible for us to know what's available on properties such as invocationContext.

@ejizba ejizba modified the milestones: June 2023, September 2023 Aug 10, 2023
@ejizba ejizba modified the milestones: September 2023, October 2023 Oct 10, 2023
@ejizba ejizba removed the v4 🚀 We no longer use this label since v4 is now the default model. label Oct 10, 2023
@ejizba ejizba assigned ejizba and unassigned hossam-nasr Oct 31, 2023
@ejizba ejizba modified the milestones: October 2023, November 2023 Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants