Unverified Commit 0a5cc30e authored by Pierre de la Martinière's avatar Pierre de la Martinière Committed by GitHub

Add NextApiHandler type (#10573)

* Add NextApiHandler type

* Fix formatting
Co-authored-by: 's avatarJoe Haddad <timer150@gmail.com>
parent db04cc57
...@@ -219,6 +219,14 @@ export type NextApiResponse<T = any> = ServerResponse & { ...@@ -219,6 +219,14 @@ export type NextApiResponse<T = any> = ServerResponse & {
clearPreviewData: () => NextApiResponse<T> clearPreviewData: () => NextApiResponse<T>
} }
/**
* Next `API` route handler
*/
export type NextApiHandler<T = any> = (
req: NextApiRequest,
res: NextApiResponse<T>
) => void
/** /**
* Utils * Utils
*/ */
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
NextComponentType, NextComponentType,
NextApiResponse, NextApiResponse,
NextApiRequest, NextApiRequest,
NextApiHandler,
// @ts-ignore This path is generated at build time and conflicts otherwise // @ts-ignore This path is generated at build time and conflicts otherwise
} from '../dist/next-server/lib/utils' } from '../dist/next-server/lib/utils'
...@@ -53,6 +54,12 @@ export type PageConfig = { ...@@ -53,6 +54,12 @@ export type PageConfig = {
} }
} }
export { NextPageContext, NextComponentType, NextApiResponse, NextApiRequest } export {
NextPageContext,
NextComponentType,
NextApiResponse,
NextApiRequest,
NextApiHandler,
}
export default next export default next
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment