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

Nitro example #1964

Open
AaronDewes opened this issue Feb 2, 2024 · 17 comments
Open

Nitro example #1964

AaronDewes opened this issue Feb 2, 2024 · 17 comments

Comments

@AaronDewes
Copy link
Member

I created an example using https://nitro.unjs.io at https://github.com/AaronDewes/probot-nitro.

Can we move this to an official Probot repo, and also add it to create-probot-app and the docs?

I think it's a good, minimal framework to use Probot with, and it works in a lot of environments with 0 configuration.

I want to make sure everything is okay with providing such an example and also adding it to the docs before spending more time on it, so the current repo is a PoC.

@Uzlopak
Copy link
Collaborator

Uzlopak commented Feb 2, 2024

So you are instantiating a Probot instance for each http request?

@AaronDewes
Copy link
Member Author

So you are instantiating a Probot instance for each http request?

Yes, Nitro is designed to also work on many serverless platforms, where this has to happen. I'm planning to optimize this for non-serverless platforms though (If possible)

@Uzlopak
Copy link
Collaborator

Uzlopak commented Feb 2, 2024

Can we have a chat on twitter?

@AaronDewes
Copy link
Member Author

AaronDewes commented Feb 2, 2024

I just benchmarked this. It's extremely fast:

https://gist.github.com/AaronDewes/3e95469b27a1822326e6230c988b59d4

Gist
Probot with Nitro. GitHub Gist: instantly share code, notes, and snippets.

@gr2m
Copy link
Contributor

gr2m commented Feb 2, 2024

instantiating a Probot instance for each http request

I don't know Nitro, but if its deployed to something like lamda, I think it would make sense to instantiate probot outside of the function so the instance is reused while the function is in hot cache?

Like here: https://github.com/wip/app/blob/f325a681379b34c9ccf0f1a35dedbd968e51c5aa/api/index.js#L4

@AaronDewes
Copy link
Member Author

instantiating a Probot instance for each http request

I don't know Nitro, but if its deployed to something like lamda, I think it would make sense to instantiate probot outside of the function so the instance is reused while the function is in hot cache?

Like here: wip/app@f325a68/api/index.js#L4

I already did that 👍

@gr2m
Copy link
Contributor

gr2m commented Feb 2, 2024

Ah okay now I see it: https://github.com/AaronDewes/probot-nitro/blob/0ae12a0d9509abf3702870c5f561254e1fdacd35/utils/probot.ts#L6. Like magic ✨

So yeah, in that case, I'd say that's standard usage of Probot in a serverless environment 👍

Happy to move it to @probotbot and make it official. In fact I got the okay to make you both org maintainers so yay welcome

@Uzlopak
Copy link
Collaborator

Uzlopak commented Feb 2, 2024

@gr2m

We, Aaron and I, discussed on twitter on what the goal is, if we want to put more stuff into octokit or more stuff into probot. Currently it is not clear to me. One hand we want to put more into octokit like octokit/app, on the other we do not want to have special case handling of vercel in @octokit/webhooks..js

But I proposed to @AaronDewes to implement two configuration options to @octokit/webhooks.js where you can pass two async functions, where the first parameter is the request. One of the functions returns the body as string, the other one returns the body as object. getBodyAsString getBodyAsObject.
Then we can pass from probot these options down to webhooks.js and make it fully controllable in probot.

@AaronDewes
Copy link
Member Author

Can this be a drop-in replacement for existing createNodeMiddleware() function?

No, it can't, it uses a complete framework.

@AaronDewes
Copy link
Member Author

@gr2m I got kicked from the org again (I assume by @entitlements 🙄)

@AaronDewes
Copy link
Member Author

I think the GitHub security team uses this to track org access. Can you check with them? Alternatively, I can also send one of them a message too , but I think it's better if you contact them.

@AaronDewes
Copy link
Member Author

Also, being kicked from the org also removed me from all repos again...

@Uzlopak
Copy link
Collaborator

Uzlopak commented Feb 2, 2024

I got kicked out from probot org also.

@gr2m
Copy link
Contributor

gr2m commented Feb 2, 2024

ugh. I'm on it.

@wolfy1339
Copy link
Collaborator

@gr2m Any news on those Probot org invite issues?

@AaronDewes
Copy link
Member Author

Me and @Uzlopak got invited by @entitlements, GitHub's official system for their orgs

@Uzlopak
Copy link
Collaborator

Uzlopak commented Mar 3, 2024

yep

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants