Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NextApiHandler type #10573

Merged
merged 3 commits into from Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/next/next-server/lib/utils.ts
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
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