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

How do I use createNodeMiddleware in Deno #348

Open
Xenfo opened this issue Sep 27, 2022 · 1 comment
Open

How do I use createNodeMiddleware in Deno #348

Xenfo opened this issue Sep 27, 2022 · 1 comment
Labels
deno Status: Blocked Some technical or requirement is blocking the issue Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects

Comments

@Xenfo
Copy link

Xenfo commented Sep 27, 2022

When I try to use this function I get the following error:

TypeError: t.writeHead is not a function
    at Object.T [as onUnhandledRequest] (https://esm.sh/v95/@octokit/app@13.0.8/deno/app.js:2:3458)
    at G (https://esm.sh/v95/@octokit/app@13.0.8/deno/app.js:2:4308)
    at Server.#respond (https://deno.land/std@0.157.0/http/server.ts:298:37)
    at Server.#serveHttp (https://deno.land/std@0.157.0/http/server.ts:340:20)

I'm assuming this function is Node only so I tried to implement a basic receiver that I could use to receive events but it errors too:

await serve(async (req) => {
  const body = await req.text();

  await app.webhooks.verifyAndReceive({
    id: req.headers.get("x-github-delivery") ?? "",
    name: req.headers.get(
      "x-github-event",
    ) as EmitterWebhookEventWithStringPayloadAndSignature["name"] ?? "",
    signature: req.headers.get("x-hub-signature-256") ?? "",
    payload: body,
  });

  return new Response("ok");
}, { port: 3000 });
TypeError: Cannot read properties of null (reading 'map')
    at o (https://esm.sh/v95/@octokit/webhooks-methods@3.0.0/deno/webhooks-methods.js:2:256)
    at y (https://esm.sh/v95/@octokit/webhooks-methods@3.0.0/deno/webhooks-methods.js:2:195)
    at async x (https://esm.sh/v95/@octokit/webhooks@10.1.5/deno/webhooks.js:2:8000)
    at async Server.serve.port (file:///home/xenfo/projects/maintainer/src/index.ts:48:3)
    at async Server.#respond (https://deno.land/std@0.157.0/http/server.ts:298:18)

So how would I create the server?

@ghost ghost added this to Inbox in JS Sep 27, 2022
@wolfy1339 wolfy1339 added Type: Support Any questions, information, or general needs around the SDK or GitHub APIs deno labels Sep 27, 2022
@ghost ghost moved this from Inbox to Support in JS Sep 27, 2022
@gr2m
Copy link
Contributor

gr2m commented Sep 27, 2022

There are compatibility problems with Octokit + Deno, it's hard to track down. I think one problem was the crypto methods used in @octokit/webhooks, the error you see might be caused by that. Your code to build a custom middleware does look correct to me.

We are working towards a native ESM Octokit at https://github.com/octokit/octokit-next.js, compatibility with Deno and other JS runtime environments is a big reason why we do that. But webhooks are not implemented yet, I'm afraid.

@gr2m gr2m added the Status: Blocked Some technical or requirement is blocking the issue label Sep 27, 2022
@ghost ghost moved this from Support to Blocked in JS Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno Status: Blocked Some technical or requirement is blocking the issue Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
No open projects
JS
  
Blocked
Development

No branches or pull requests

3 participants