Repository: octokit/webhooks.js (ts)

Issue:
Deprecate `createWebhooksApi`
The `createWebhooksApi` export is there for legacy reasons. We use constructors across the other @octokit modules

https://github.com/octokit/webhooks.js/blob/1891034b602a2193a08f1ac3ad31775df65ca578/src/index.ts#L69

We should deprecate `createWebhooksApi` by exporting a function with that name that logs a deprecation message and returns a `Webhooks` instance with the same options, then remove it as v9. 

I like creating a dedicated `deprecations-test.ts` file where we test that the deprecation message is logged and that the API still works. If we stay consistent with that flow, removing deprecated APIs as part of a breaking release becomes trivial

Pull request description:
feat: deprecate `createWebhooksApi()`
Fixes #454

Patch:
diff --git a/src/index.ts b/src/index.ts
index 12ac19d..23c1e86 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -65,7 +65,13 @@ class Webhooks<TTransformed> {
   }
 }
 
-const createWebhooksApi = Webhooks.prototype.constructor;
+/** @deprecated `createWebhooksApi()` is deprecated and will be removed in a future release of `@octokit/webhooks`, please use the `Webhooks` class instead */
+const createWebhooksApi = <TTransformed>(options: Options<TTransformed>) => {
+  console.error(
+    "[@octokit/webhooks] `createWebhooksApi()` is deprecated and will be removed in a future release of `@octokit/webhooks`, please use the `Webhooks` class instead"
+  );
+  return new Webhooks<TTransformed>(options);
+};
 
 export {
   createEventHandler,


Test patch:
diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts
index 400dbb2..19731e6 100644
--- a/test/typescript-validate.ts
+++ b/test/typescript-validate.ts
@@ -2,7 +2,6 @@ import {
   Webhooks,
   createEventHandler,
   createMiddleware,
-  createWebhooksApi,
   sign,
   verify,
   EmitterWebhookEvent,
@@ -78,11 +77,6 @@ export default async function () {
     },
   });
 
-  // Check named exports of new API work
-  createWebhooksApi({
-    secret: "blah",
-  });
-
   createEventHandler({ secret: "blah" });
 
   createMiddleware({
diff --git a/test/unit/deprecation.test.ts b/test/unit/deprecation.test.ts
new file mode 100644
index 0000000..ab4c36d
--- /dev/null
+++ b/test/unit/deprecation.test.ts
@@ -0,0 +1,12 @@
+import { createWebhooksApi } from "../../src";
+
+describe("Deprecated methods", () => {
+  test("createWebhooksApi", () => {
+    const spy = jest.spyOn(console, "error");
+    createWebhooksApi({ secret: "foo" });
+    expect(spy).toBeCalledWith(
+      "[@octokit/webhooks] `createWebhooksApi()` is deprecated and will be removed in a future release of `@octokit/webhooks`, please use the `Webhooks` class instead"
+    );
+    spy.mockClear();
+  });
+});