-
Notifications
You must be signed in to change notification settings - Fork 7
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
Support for async/await with typescript? #5
Comments
@jsancho I made a PR #13 I hope that @emanuelcasco could review it and merge it as soon as possible |
For someone that is finding a solution similar to middy and full typescript support can take a look at @racy/azure-middleware package. |
Just following up after a long time - I have exactly the same issue @jsancho. How did you solve this? The approach I thought of taking was to have nested try catch to first verify the token, then pass it to another try catch to fetch protected resources. Hacky at best. |
I did not end up using this project after all. Mind, that It's been more than 2 years since I opened this issue and things have changed for the better with the Azure Functions SDK. Azure Functions v4 can now be created with a typescript template and support for The documentation could be a little bit more organised, but it's definitely doable. What I ended up doing in my case for auth purposes, was to have a helper function in a shared file that did the token verification.
Not an ideal config, because it peppers a fair bit of boilerplate to every function. |
Thanks for the response. I ended up solving it in a similar fashion. A helper isAuth method with context as a parameter, erroring out in the helper function if something happened. Then a simple if check wrapped around the business logic to see if a token was returned from the helper. Not the finest code to exist but it works and some rudimentary checks with postman seems to be fine. In terms of middleware solutions, scouring the web yielded very little. So a helper function was the best way forward. All the best |
Hi Emmanuel,
I've absolutely loved the approach on this project.
It does open up a familiar and elegant mechanism to plug common functionality that is sadly missing from the official SDK.
In my case, I have a custom handler to validate JWT from a provider that is not supported by Azure Functions.
The issue is that my project is using typescript and the async/await pattern, so it couldn't work out of the box.
I've butchered your code to the best of my abilities, but not gotten all that far - I'm more of a c# dev.
What I've managed to use handler to invoke my logic and do the JWT validation but I'm at a loss on how to do the hand-off from the middleware back to the entry function.
Seeing that there's been official typescript support from Microsoft for a while.
Would you consider adding support for it?
I'd be absolutely invaluable for me and I bet many others as well :)
The text was updated successfully, but these errors were encountered: