Skip to content

Replace webhooks.middleware with createNodeMiddleware() #507

@gr2m

Description

@gr2m

What’s missing?

For better consistency with other modules (compare https://github.com/octokit/app.js/, https://github.com/octokit/oauth-app.js/), better compatibility with browsers, and better composability, we should

  1. Export a createNodeMiddleware(app, { path }) function
  2. Deprecate webhooks.middleware and the path constuctor option
  3. Default the webhooks path to /api/github/webhooks, for better compatibility with the defaults of https://github.com/octokit/oauth-app.js#createnodemiddlewareapp-options

Why?

http request routing is not a concern of the @octokit/webhooks library. When it was created, long-living node processes were the norm. Today, serverless enviroments gain more and more traction, and they come with their own http routing. Moving it out of the core library will make it easier to use in serverless environments, and easier to compose with other libraries, such as https://github.com/octokit/app.js/, https://github.com/octokit/octokit.js, and github.com/probot/probot/

Alternatives you tried

It's possible to use & compose the library as is today, but it's unnecessary complicated.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions