Skip to content

Commit

Permalink
Fix TypedNextResponse usage
Browse files Browse the repository at this point in the history
The custom typings do not implement
the same constuctor as the original
NextResponse class, so we apply the
custom types to the original NextResponse
class when exporting the module instead.
  • Loading branch information
blomqma committed Oct 24, 2023
1 parent c6b1871 commit a4cc33d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/next-rest-framework/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { NextResponse } from 'next/server';
import { type TypedNextResponse as TypedNextResponseType } from './types';
export {
routeHandler,
routeOperation,
apiRouteHandler,
apiRouteOperation
} from './route-handlers';
export { docsRouteHandler, docsApiRouteHandler } from './docs-handlers';
export { TypedNextResponse } from './types';

// @ts-expect-error - Keep the original NextResponse functionality with custom types.
export const TypedNextResponse: typeof TypedNextResponseType = NextResponse;
2 changes: 1 addition & 1 deletion packages/next-rest-framework/src/types/route-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export type RouteOperation = (
export type NextRouteHandler = (
req: NextRequest,
context: { params: BaseQuery }
) => Promise<NextResponse>;
) => Promise<NextResponse> | NextResponse | Promise<void> | void;

export interface RouteOperationDefinition {
_config: {
Expand Down

0 comments on commit a4cc33d

Please sign in to comment.