Skip to content

Commit b9d923e

Browse files
authored
fix(nextjs): Use NextApiHandler type in withSentry (#3506)
1 parent 4092d66 commit b9d923e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/nextjs/src/utils/handlers.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { captureException, flush, Handlers, withScope } from '@sentry/node';
22
import { addExceptionMechanism } from '@sentry/utils';
3-
import { NextApiRequest, NextApiResponse } from 'next';
3+
import { NextApiHandler } from 'next';
44

55
const { parseRequest } = Handlers;
66

7+
// purely for clarity
8+
type WrappedNextApiHandler = NextApiHandler;
9+
710
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
8-
export const withSentry = (handler: (req: NextApiRequest, res: NextApiResponse) => Promise<void>) => {
11+
export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
912
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
10-
return async (req: NextApiRequest, res: NextApiResponse) => {
13+
return async (req, res) => {
1114
try {
1215
// TODO: Start Transaction
1316
return await handler(req, res); // Call Handler

0 commit comments

Comments
 (0)