Skip to content

Commit d569f8d

Browse files
committed
fix: cast to WebhookEvent earlier
1 parent 11e31bc commit d569f8d

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/handler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { UrlConfig } from "./types.d.ts";
99
import { parseBool } from "./util.ts";
1010

1111
export default async function handle(
12-
json: Record<string, any>,
12+
json: WebhookEvent,
1313
headers: Record<string, string>,
1414
queryParams: Record<string, string>,
1515
id: string,
@@ -18,7 +18,7 @@ export default async function handle(
1818
const urlConfig = getUrlConfig(queryParams);
1919

2020
// do the thing
21-
const filterReason = await filterWebhook(headers, json as WebhookEvent, urlConfig);
21+
const filterReason = await filterWebhook(headers, json, urlConfig);
2222
if (filterReason !== null) {
2323
const reqLog = getRequestLog();
2424
reqLog.debug(`handler: ignored due to '${filterReason}'`);

src/server/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Hono } from "@hono/hono";
22
import { HTTPException } from "@hono/hono/http-exception";
33
import { logger } from "@hono/hono/logger";
4+
import { WebhookEvent } from "@octokit/webhooks-types";
45

56
import config from "../config.ts";
67
import { contextMiddleware, getRequestLog } from "./context.ts";
@@ -39,7 +40,7 @@ app.post("/:id/:token", async (c) => {
3940
}
4041
}
4142

42-
const data = await c.req.json();
43+
const data = await c.req.json() as WebhookEvent;
4344
let [res, meta] = await handler(data, c.req.header(), c.req.query(), id, token);
4445

4546
// clone response to make headers mutable

0 commit comments

Comments
 (0)