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

feat: deprecate createWebhooksApi() #511

Merged
merged 3 commits into from
Mar 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions test/typescript-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Webhooks,
createEventHandler,
createMiddleware,
createWebhooksApi,
sign,
verify,
EmitterWebhookEvent,
Expand Down Expand Up @@ -78,11 +77,6 @@ export default async function () {
},
});

// Check named exports of new API work
createWebhooksApi({
secret: "blah",
});

createEventHandler({ secret: "blah" });

createMiddleware({
Expand Down
12 changes: 12 additions & 0 deletions test/unit/deprecation.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});