UNPKG

@defikitdotnet/education-module-ai

Version:
17 lines (16 loc) 916 B
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'; export interface ApiMethodHandlers { get?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>; post?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>; put?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>; delete?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>; patch?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>; [key: string]: ((req: NextApiRequest, res: NextApiResponse) => Promise<void>) | undefined; } /** * Creates an API handler that routes to the appropriate method handler based on the HTTP method * @param handlers Object with method handlers (get, post, put, delete, patch) * @returns A Next.js API handler */ export declare function createMethodHandler(handlers: ApiMethodHandlers): NextApiHandler; export default createMethodHandler;