Skip to content

Commit

Permalink
Add NextApiHandler type
Browse files Browse the repository at this point in the history
  • Loading branch information
martpie committed Feb 18, 2020
1 parent c71fcbe commit 58477b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/next/next-server/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ export type NextApiResponse<T = any> = ServerResponse & {
clearPreviewData: () => NextApiResponse<T>
}

/**
* Next `API` route handler
*/
export type NextApiHandler<T = any> = (req: NextApiRequest, res: NextApiResponse<T>) => void;


/**
* Utils
*/
Expand Down
9 changes: 8 additions & 1 deletion packages/next/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
NextComponentType,
NextApiResponse,
NextApiRequest,
NextApiHandler,
// @ts-ignore This path is generated at build time and conflicts otherwise
} from '../dist/next-server/lib/utils'

Expand Down Expand Up @@ -53,6 +54,12 @@ export type PageConfig = {
}
}

export { NextPageContext, NextComponentType, NextApiResponse, NextApiRequest }
export {
NextPageContext,
NextComponentType,
NextApiResponse,
NextApiRequest,
NextApiHandler,
}

export default next

0 comments on commit 58477b6

Please sign in to comment.